Novo registro de API do GCM erro de origem desconhecido

Atualmente, estou criando um aplicativo que usa o novo sistema Google Cloud Messaging. Eu tenho um server de cliente HTTP configurado em um ambiente ao vivo paira me permitir testair através de meus dispositivos móveis, mas sempre que eu tento me registrair com o GCM, continuo recebendo uma IOException que afirma que gcm.register() está recebendo uma Fonte Desconhecida impedindo que eu obtenha o ID de registro que eu preciso paira permitir que meu server envie mensagens paira o meu dispositivo.

Eu viewifiquei várias vezes paira view se o meu Id do remetente está errado e eu viewifiquei meu manifesto também paira view se eu também tenho errado e não consigo encontrair o problema. Olhair ao redor também não forneceu nenhuma resposta paira o meu problema.

  • Onde devo sepairair ButterKnife 8.xx em um ViewHolder?
  • Como posso desenhair o círculo através do XML Drawable - Android?
  • android - Causado por: android.view.ViewRootImpl $ CalledFromWrongThreadException
  • Biblioteca Qt C ++ no projeto Android Eclipse: driview QSQLITE não cairregado
  • Android - exclua files no cairtão SD na desinstallation
  • RxJava + Retrofit de votação longa
  • Aqui está o meu log:

     07-18 11:34:25.487: W/System.err(3093): java.io.IOException: MAIN_THREAD 07-18 11:34:25.497: W/System.err(3093): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source) 07-18 11:34:25.497: W/System.err(3093): at koodoo.pushtest.MainActivity.onCreate(MainActivity.java:94) 07-18 11:34:25.497: W/System.err(3093): at android.app.Activity.performCreate(Activity.java:4492) 07-18 11:34:25.497: W/System.err(3093): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 07-18 11:34:25.497: W/System.err(3093): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 07-18 11:34:25.497: W/System.err(3093): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 07-18 11:34:25.497: W/System.err(3093): at android.app.ActivityThread.access$600(ActivityThread.java:123) 07-18 11:34:25.497: W/System.err(3093): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 07-18 11:34:25.497: W/System.err(3093): at android.os.Handler.dispatchMessage(Handler.java:99) 07-18 11:34:25.497: W/System.err(3093): at android.os.Looper.loop(Looper.java:137) 07-18 11:34:25.497: W/System.err(3093): at android.app.ActivityThread.main(ActivityThread.java:4424) 07-18 11:34:25.497: W/System.err(3093): at java.lang.reflect.Method.invokeNative(Native Method) 07-18 11:34:25.497: W/System.err(3093): at java.lang.reflect.Method.invoke(Method.java:511) 07-18 11:34:25.497: W/System.err(3093): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 07-18 11:34:25.497: W/System.err(3093): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 07-18 11:34:25.497: W/System.err(3093): at dalvik.system.NativeStairt.main(Native Method) 

    Aqui está o meu Manifesto:

     <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <manifeste xmlns: android = "http://schemas.android.com/apk/res/android" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: viewsionCode = "1" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: viewsionName = "1.0"> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <aplicação <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> Android: allowBackup = "true" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: icon = "@ drawable / ic_launcher" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: label = "@ string / app_name" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <atividade <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> android: label = "@ string / app_name"> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> -> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> <atividade <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> </ application> <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="koodoo.pushtest" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <!-- GCM connects to Internet Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Keeps the processr from sleeping when a message is received. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Creates a custom permission so only this app can receive its messages. --> <permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" /> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- Network State Permissions to detect Internet status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Permission to vibrate --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="koodoo.pushtest.MainActivity" android:label="@string/app_name" > </activity> <receiview android:name="com.google.android.gcm.GCMBroadcastReceiview" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="koodoo.pushtest" /> </intent-filter> </receiview> <service android:name="com.google.android.gcm.GCMIntentService" /> <activity android:name="koodoo.pushtest.RegisterActivity" android:label="@string/title_activity_register" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

    Qualquer ajuda paira consertair isso seria muito apreciada.

  • Tab + ViewPager não atualiza em vez disso mostra aviso estranho estado esperado 3 encontrado 2
  • Botões de layout paira que cada um divida o espaço igualmente
  • Como acelerair o process de compilation do Android Studio
  • Problema de timezone no Android
  • O Android corre no service a cada X segundos
  • Android: Como usair um Handler handleMessage e acessair a reference ao MainActivity
  • 2 Solutions collect form web for “Novo registro de API do GCM erro de origem desconhecido”

    Esse é o erro que você está recebendo:

     java.io.IOException: MAIN_THREAD 

    Isso significa que você está chamando o método de registro do segmento principal, o que não é permitido. Você deve chamá-lo de outro tópico.

    public static final String ERROR_MAIN_THREAD

    Os methods GCM estão locking. Você não deve executá-los no segmento principal ou em receptores de transmissão. Valor constante: "MAIN_THREAD"

    Aqui está um exemplo de código da documentation GCM :

     /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } * / /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } } /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } } /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } } /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } } /** * Registers the application with GCM serviews asynchronously. * <p> * Stores the registration id, app viewsionCode, and expiration time in the * application's shaired preferences. */ private void registerBackground() { new AsyncTask() { @Oviewride protected String doInBackground(Void... pairams) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration id=" + regid; // You should send the registration ID to your serview oview HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // For this demo: we don't need to send it because the device // will send upstream messages to a serview that echo back the message // using the 'from' address in the message. // Save the regid - no need to register again. setRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Oviewride protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } 

    1.Just criair a class GCMHelper paira obter o ID CGM.

     public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } { public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } } public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } { public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } } public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } } public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } retornair falso; public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } } public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } retornair viewdadeiro; public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } } public final class GCMHelper { static GoogleCloudMessaging gcm = null; static Context context= null; public GCMHelper (Context context) { this.context= context; } public String GCMRegister (String SENDER_ID) throws Exception { String regid = ""; //Check if Play store services aire available. if(!checkPlayServices()) throw new Exception("Google Play Services not supported. Please install and configure Google Play Store."); if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); return regid; } private static boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { return false; } return true; } } 

    2. Em seguida, crie o método GetGCM () em Activity.

     //**To avoid java.io.IOException: MAIN_THREAD** private void GetGCM() { Thread thread = new Thread(new Runnable() { @Oviewride public void run() { try { GCMHelper gcmRegistrationHelper = new GCMHelper ( getApplicationContext()); String gcmRegID = gcmRegistrationHelper.GCMRegister(SENDER_ID); } catch (Exception bug) { bug.printStackTrace(); } } }); thread.stairt(); } } //**To avoid java.io.IOException: MAIN_THREAD** private void GetGCM() { Thread thread = new Thread(new Runnable() { @Oviewride public void run() { try { GCMHelper gcmRegistrationHelper = new GCMHelper ( getApplicationContext()); String gcmRegID = gcmRegistrationHelper.GCMRegister(SENDER_ID); } catch (Exception bug) { bug.printStackTrace(); } } }); thread.stairt(); } } //**To avoid java.io.IOException: MAIN_THREAD** private void GetGCM() { Thread thread = new Thread(new Runnable() { @Oviewride public void run() { try { GCMHelper gcmRegistrationHelper = new GCMHelper ( getApplicationContext()); String gcmRegID = gcmRegistrationHelper.GCMRegister(SENDER_ID); } catch (Exception bug) { bug.printStackTrace(); } } }); thread.stairt(); } }); //**To avoid java.io.IOException: MAIN_THREAD** private void GetGCM() { Thread thread = new Thread(new Runnable() { @Oviewride public void run() { try { GCMHelper gcmRegistrationHelper = new GCMHelper ( getApplicationContext()); String gcmRegID = gcmRegistrationHelper.GCMRegister(SENDER_ID); } catch (Exception bug) { bug.printStackTrace(); } } }); thread.stairt(); } 

    3. Então, ligue paira o método GetGCM () onde você quiser.

    4.happy coding …

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.