android - Getting error "Acquiring wakelock" while getting regid in GCM -


i trying create push notification app using anrdoid , php. want device reg id can use in php. there problem in getting reg id getting following error

acquiring wakelock

below code trying

package com.example.pushex;  import java.util.timer; import java.util.timertask;  import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import android.content.context; import android.content.intent; import android.os.powermanager; import android.util.log;  import com.google.android.gcm.gcmbaseintentservice;  public class gcmintentservic extends gcmbaseintentservice {   private static final string tag = "gcm tutorial::service";   // use project id google api sender_id  public static final string sender_id = "1073553515893";   public static string deviceid;   public gcmintentservic() {    super(sender_id);   }   @override  protected void onregistered(context context, string registrationid) {    log.i(tag, "onregistered: registrationid=" + registrationid);   log.i(tag, "onregistered: registrationid=" + registrationid);    deviceid = registrationid;   }   @override  protected void onunregistered(context context, string registrationid) {    log.i(tag, "onunregistered: registrationid=" + registrationid);   log.i(tag, "onunregistered: registrationid=" + registrationid);    deviceid = registrationid;   }   @override  protected void onmessage(context context, intent data) {   string message;   // message php server   message = data.getstringextra("message");   // open new activity called gcmmessageview   intent intent = new intent(this, gcmmessageview.class);   // pass data new activity   intent.putextra("message", message);   // starts activity on notification click   pendingintent pintent = pendingintent.getactivity(this, 0, intent,     pendingintent.flag_update_current);   // create notification notification builder   notification notification = new notification.builder(this)     .setsmallicon(r.drawable.ic_launcher)     .setwhen(system.currenttimemillis())     .setcontenttitle("android gcm tutorial")     .setcontenttext(message).setcontentintent(pintent)     .getnotification();   // remove notification on click   notification.flags |= notification.flag_auto_cancel;    notificationmanager manager = (notificationmanager) getsystemservice(notification_service);   manager.notify(r.string.app_name, notification);    {    // wake android device when notification received    powermanager pm = (powermanager) context      .getsystemservice(context.power_service);    final powermanager.wakelock mwakelock = pm.newwakelock(      powermanager.full_wake_lock        | powermanager.acquire_causes_wakeup, "gcm_push");    mwakelock.acquire();     // timer before putting android device sleep mode.    timer timer = new timer();    timertask task = new timertask() {     public void run() {      mwakelock.release();     }    };    timer.schedule(task, 5000);   }   }   @override  protected void onerror(context arg0, string errorid) {    log.e(tag, "onerror: errorid=" + errorid);  }  } 

this menifest

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.pushex"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="11"         android:targetsdkversion="21" />      <permission         android:name="com.example.pushex.permission.c2d_message"         android:protectionlevel="signature" />      <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="com.example.pushex.permission.c2d_message" />     <uses-permission android:name="com.google.android.c2dm.permission.receive" />     <uses-permission android:name="android.permission.wake_lock" />      <application         android:allowbackup="false"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name" >         <activity             android:name=".gcmmainactivity"             android:launchmode="singletask" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>         <activity android:name=".gcmmessageview" >         </activity>          <service android:name=".gcmintentservic" />          <receiver             android:name="com.google.android.gcm.gcmbroadcastreceiver"             android:permission="com.google.android.c2dm.permission.send" >             <intent-filter>                 <action android:name="com.google.android.c2dm.intent.receive" />                 <action android:name="com.google.android.c2dm.intent.registration" />                  <category android:name="com.example.pushex" />             </intent-filter>         </receiver>          <meta-data             android:name="com.google.android.gms.version"             android:value="@integer/google_play_services_version" />     </application>  </manifest> 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -