java - Broadcast receiver on app closed (or in the background) -


i create simple alarms app , have 2 broadcast receivers registered in androidmanifest.xml (one receiving alarms , other rescheduling them on device boot). after scheduling alarms reboot device , "onboot" receiver rescheduling alarms well, first receiver doesn't recive them. if start app, schedule alarms , won't close it, receiver work fine, if close (not force stop) app or send background pressing home button, receiver never receive alarms! tested on several devices (htc, meizu, samsung) , got same problem. there 1 way found make receiver work kill app, because after start again, receiver working app closed, after reboot device again same problem. please, can me that? need rid of problem?

i tried everything(changing pendingintent flags , request codes, running receivers in remote processes, setting intent-filters, extend wakefulbroadcastreceiver , many other) nothing has helped me.

receivers in androidmanifest.xml

    <receiver         android:name="com.gd.aiwnext.deal.receivers.notificationsreceiver"         android:enabled="true"         android:exported="true"         android:process=":nr">         <intent-filter>             <action android:name="com.gd.action.intent.bri"></action>         </intent-filter>     </receiver>      <receiver         android:name="com.gd.aiwnext.deal.receivers.notificationbootreceiver"         android:process=":nbr">         <intent-filter>             <action android:name="android.intent.action.boot_completed" />             <category android:name="android.intent.category.default" />             <action android:name="android.intent.action.quickboot_poweron" />         </intent-filter>     </receiver> 

broadcastreceiver

public class notificationsreceiver extends wakefulbroadcastreceiver {  sqlitedatabase notedatabase; notesdatabase notesdatabase; string olddate, newdate, intpicker, oldtime, newtime; string newyear, newmonth, newday, newhour, newminute; long currenttimeinmillis, futuretimeinmillis; boolean startaftersleep;  string finalhour = "", finalminute = "", finalyear = "", finalmonth = "", finalday = ""; boolean isdivided = false;  @override public void onreceive(context context, intent intent) {     log.d("bll","simple");     int id = intent.getintextra("id", 1);     string note = intent.getstringextra("note");     string interval = intent.getstringextra("interval");     olddate = intent.getstringextra("date");     oldtime = intent.getstringextra("time");     intpicker = intent.getstringextra("intpicker");     currenttimeinmillis = intent.getlongextra("timeinmillis", 0);     if (intent.hasextra("startaftersleep")) {         startaftersleep = (intent.getbooleanextra("startaftersleep", false));     } else {         startaftersleep = false;     }     createnotification(id, note, interval, context); } 

i use createnotification() method send notifications , database update time , date of alarm.

creating alarms

intent intent = new intent("com.gd.action.intent.bri"); 

after put extra, and

pendingintent pendingintent = pendingintent.getbroadcast(getcontext(), idcount, intent, pendingintent.flag_one_shot); alarmmanager.setexact(alarmmanager.rtc_wakeup, futuretimemillis, pendingintent); 

you should apply default category

<category android:name="android.intent.category.default" /> 

android assign category each intent if category isn't specified.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -