- public static String getRegistrationId(Context context) {
- GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
-
- String registrationId = null;
- try {
- registrationId = gcm.register(Consts.PROJECT_NUMBER);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return registrationId;
- }
public static String getRegistrationId(Context context) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String registrationId = null;
try {
registrationId = gcm.register(Consts.PROJECT_NUMBER);
} catch (IOException e) {
e.printStackTrace();
}
return registrationId;
}
を呼んでるんだけど null が返ってくる、なぜだ。。。と思っていたら、IOException が発生していた。。。
- 10-01 18:17:18.489: W/System.err(6397): java.io.IOException: MAIN_THREAD
- 10-01 18:17:18.489: W/System.err(6397): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
10-01 18:17:18.489: W/System.err(6397): java.io.IOException: MAIN_THREAD
10-01 18:17:18.489: W/System.err(6397): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
UIスレッドで呼んじゃいけないのか。リファレンスに書いておいてほしかったなー。。。
と思ったら
register() のリファレンスには書いてないのに、なぜか
エラーコードのリファレンスにだけ書いてあるとか。ううう。
0 件のコメント:
コメントを投稿