android - Code gets stuck at acquiring wake lock while registering with GCM -


i using gcm push notifications project, stuck @ acquiring wake lock.

log message:

09-03 17:04:05.003: v/gcmbroadcastreceiver(5772): onreceive:com.google.android.c2dm.intent.registration 09-03 17:04:05.003: v/gcmbroadcastreceiver(5772): gcm intentservice class: example.pro.gcmintentservice 09-03 17:04:05.049: v/gcmbaseintentservice(5772): acquiring wakelock 

below manifest file:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="example.pro"     android:versioncode="1"     android:versionname="1.0" >     <uses-sdk         android:minsdkversion="16"         android:targetsdkversion="17" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.access_fine_location" />     <uses-permission android:name="android.permission.access_network_state" />     <!-- gcm requires google account. -->     <uses-permission android:name="android.permission.get_accounts" />     <!-- keeps processor sleeping when message received. -->     <uses-permission android:name="android.permission.wake_lock" />     <!-- creates custom permission app can receive messages. -->     <permission         android:name="example.pro.permission.c2d_message"         android:protectionlevel="signature" />     <uses-permission android:name="example.pro.permission.c2d_message" />     <!-- app has permission register , receive data message. -->     <uses-permission android:name="com.google.android.c2dm.permission.receive" />     <!-- network state permissions detect internet status -->     <uses-permission android:name="android.permission.access_network_state" />     <!-- permission vibrate -->     <uses-permission android:name="android.permission.vibrate" />     <application         android:name="com.thinkappz.advancedtictactoe.friendpickerapplication"         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@android:style/theme.notitlebar" >         <activity             android:name="com.thinkappz.advancedtictactoe.splash"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>         <activity             android:name="com.google.ads.adactivity"             android:configchanges="keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize" />         <activity             android:name="com.thinkappz.advancedtictactoe.mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name=".mainactivity" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.gcmmainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name=".gcmmainactivity" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.newgame"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.newgame" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.vs_facebook"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.vs_facebook" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.randomplayer"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.randomplayer" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.register"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.register" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.registeractivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.registeractivity" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.sendrequest"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.sendrequest" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.pickfriendsactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.pickfriendsactivity" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.getfinishedgames"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.getfinishedgames" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <activity             android:name="com.thinkappz.advancedtictactoe.homescreen"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="example.pro.homescreen" />                 <category android:name="android.intent.category.default" />             </intent-filter>         </activity>         <meta-data             android:name="com.facebook.sdk.applicationid"             android:value="@string/app_id" />         <activity android:name="com.facebook.loginactivity" />         <receiver             android:name="com.google.android.gcm.gcmbroadcastreceiver"             android:permission="com.google.android.c2dm.permission.send" >             <intent-filter>                 <!-- receives actual messages. -->                 <action android:name="com.google.android.c2dm.intent.receive" />                 <!-- receives registration id. -->                 <action android:name="com.google.android.c2dm.intent.registration" />                 <category android:name="example.pro" />             </intent-filter>         </receiver>         <service android:name="com.thinkappz.advancedtictactoe.gcmintentservice" />     </application> </manifest> 

gcmintentservice----> class file inside com.thinkappz.advancedtictactoe package, r.java file generated inside example.pro. don't know why.

package com.thinkappz.advancedtictactoe;  import javax.management.notification;  public class gcmintentservice extends gcmbaseintentservice {      private static final string tag = "gcmintentservice";      public gcmintentservice() {         super(sender_id);     }      /**      * method called on device registered      **/     @override     protected void onregistered(context context, string registrationid) {         log.i(tag, "device registered: regid = " + registrationid);         displaymessage(context, "your device registred gcm");         log.d("name", gcmmainactivity.name);         serverutilities.register(context, gcmmainactivity.name,             gcmmainactivity.email, registrationid);     }      /**      * method called on device un registred      * */     @override     protected void onunregistered(context context, string registrationid) {         log.i(tag, "device unregistered");         displaymessage(context, getstring(r.string.gcm_unregistered));         serverutilities.unregister(context, registrationid);     }      /**      * method called on receiving new message      * */     @override     protected void onmessage(context context, intent intent) {         log.i(tag, "received message");         string message = intent.getextras().getstring("price");         displaymessage(context, message);         // notifies user         generatenotification(context, message);     }      /**      * method called on receiving deleted message      * */     @override     protected void ondeletedmessages(context context, int total) {         log.i(tag, "received deleted messages notification");         string message = getstring(r.string.gcm_deleted, total);         displaymessage(context, message);         // notifies user         generatenotification(context, message);     }      /**      * method called on error      * */     @override     public void onerror(context context, string errorid) {         log.i(tag, "received error: " + errorid);         displaymessage(context, getstring(r.string.gcm_error, errorid));     }      @override     protected boolean onrecoverableerror(context context, string errorid) {         // log message         log.i(tag, "received recoverable error: " + errorid);         displaymessage(context,             getstring(r.string.gcm_recoverable_error, errorid));         return super.onrecoverableerror(context, errorid);     }      /**      * issues notification inform user server has sent message.      */     private static void generatenotification(context context, string message) {         int icon = r.drawable.ic_launcher;         long when = system.currenttimemillis();         notificationmanager notificationmanager = (notificationmanager) context                 .getsystemservice(context.notification_service);         notification notification = new notification(icon, message, when);         string title = context.getstring(r.string.app_name);         intent notificationintent = new intent(context, mainactivity.class);         // set intent not start new activity         notificationintent.setflags(intent.flag_activity_clear_top             | intent.flag_activity_single_top);         pendingintent intent = pendingintent.getactivity(context, 0,             notificationintent, 0);         notification.setlatesteventinfo(context, title, message, intent);         notification.flags |= notification.flag_auto_cancel;         // play default notification sound         notification.defaults |= notification.default_sound;         // notification.sound = uri.parse("android.resource://" +         // context.getpackagename() + "your_sound_file_name.mp3");         // vibrate if vibrate enabled         notification.defaults |= notification.default_vibrate;         notificationmanager.notify(0, notification);     } } 

i tried <service android:name="example.pro.gcmintentservice" /> giving me error while registering, saying can't instantiate service.

you using com.google.android.gcm.gcmbroadcastreceiver broadcast receiver google gcm client library. class expects intent service in main package of app (example.pro) intent service in different package - com.thinkappz.advancedtictactoe. that's why receiver can't find service.

you should either move gcmintentservice main package of app, or override gcmbroadcastreceiver.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -