Android AlarmManager won't call BroadcastReceiver -


i'm trying call alarmreceiver extends broadcastreceiver. after run code, can't see of logs. please me in issue. :d

here's try call alarmreceiber

        public void downloadtweets(context context) {         connectivitymanager connmgr = (connectivitymanager) context.getsystemservice(context.connectivity_service);         networkinfo networkinfo = connmgr.getactivenetworkinfo();           if (networkinfo != null && networkinfo.isconnected()) {               intent alarmintent = new intent(context,appservice.alarmreceiver.class);             alarmintent.putextra(appservice.screen_name, screenname);              pendingintent pi = pendingintent.getbroadcast(context,0,alarmintent,pendingintent.flag_update_current);//getbroadcast(context, 0, i, 0);              alarmmanager am=(alarmmanager) context.getsystemservice(context.alarm_service);             log.v(log_tag, "shot");             am.set(alarmmanager.rtc_wakeup, system.currenttimemillis() + 1, pi);              log.v(log_tag, "shot finish");           } else {             log.v(log_tag, "no network connection available.");         }     } 

and here's alarmreceiver class sub-class of appservice

  public static class alarmreceiver extends broadcastreceiver {   @override   public void onreceive(context context, intent intent) {       log.v(log_tag, "alarmreceiver");        intent sendintent = new intent(context,appservice.class);       sendintent.putextra(appservice.screen_name,intent.getstringextra(appservice.screen_name));       context.startservice(sendintent);       log.v(log_tag, "alarmreceiver done");     }  } 

and manifest has this...

<?xml version="1.0" encoding="utf-8"?> 

<application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.nutjane.android.rainalert.mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application>  <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" />  <service android:name=".service.appservice"/> <receiver android:name=".service.appservice$alarmreceiver" android:enabled="true"/> 

when run, log shows shot , shot finish

could please me solve issue.

add:

 sendintent.setflags(intent.flag_activity_new_task); 

in alarmreceiver class

change manifest file to:

       <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity     android:name="com.nutjane.android.rainalert.mainactivity"     android:label="@string/app_name" >     <intent-filter>         <action android:name="android.intent.action.main" />          <category android:name="android.intent.category.launcher" />     </intent-filter>   </activity>     <service         android:name=".appservice"         android:enabled="true" />      <receiver android:name=".alarmreceiver" >         <intent-filter>             <action android:name="myintent" />         </intent-filter>     </receiver>    </application>   <uses-permission android:name="android.permission.internet" />  <uses-permission android:name="android.permission.access_network_state" /> 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -