c# - Xamarin.Android Service doesnt restart on Reboot "App Stopped" Message -


i using service alarmmanager every 30 minutes triggers "service receiver" used scheduling notification.for purpose of testing have lowered interval.my app , service runs fine , able deliver notifications.however after reboot service stops abruptly , message delivered saying "app stopped working".

i have written code inspired here, here , many other questions , have been trying solve issue past 12 hours.i suspect issue in rebootreceiver or manifest. code simple , works others.

my app manifest :

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="namaz_pro.namaz_pro" android:versioncode="1" android:versionname="1.0" android:installlocation="preferexternal">     <uses-sdk android:minsdkversion="17" />     <uses-permission android:name="android.permission.access_fine_location" />     <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_network_state" />     <uses-permission android:name="android.permission.wake_lock" />     <uses-permission android:name="android.permission.receive_boot_completed" />     <application android:label="namaz pro">          <receiver android:name=".servicereceiver" />         <receiver android:name=".notificationpublisher" />     <receiver android:name=".rebootreceiver"               android:permission="android.permission.receive_boot_completed">       <intent-filter>         <category android:name="android.intent.category.default" />        <action android:name="android.intent.action.boot_completed" />       <action android:name="android.intent.action.quickboot_poweron"/>       </intent-filter>     </receiver>     <service android:name=".notificationservice"/>     </application> </manifest> 

my rebootreceiver :

[broadcastreceiver]     class rebootreceiver : broadcastreceiver     {         public override void onreceive(context context, intent intent)         {             if ("android.intent.action.boot_completed".equals(intent.action))             {                  intent startserviceintent = new intent(context, typeof(notificationservice));                 context.startservice(startserviceintent);             }          }     } 

my service :

[service]     class notificationservice : android.app.service     {            public override startcommandresult onstartcommand(intent intent, [generatedenum] startcommandflags flags, int startid)         {                var alarmintent = new intent(this, typeof(servicereceiver));             var pending = pendingintent.getbroadcast(this, 1234567, alarmintent, pendingintentflags.updatecurrent);              var alarmmanager = getsystemservice(alarmservice) alarmmanager;             alarmmanager.setrepeating(alarmtype.rtcwakeup, app_code.helpermethods.currenttimemillis() + 10000, 60000 , pending);               return startcommandresult.notsticky;         }         public override void ondestroy()         {             base.ondestroy();              //log.debug(tag, "simple service destroyed @ {0}.", datetime.utcnow);         }            public override ibinder onbind(intent intent)         {              return null;         }     } 

my service receiver :

[broadcastreceiver] public class servicereceiver : broadcastreceiver {         notificationhelper.setupnotifications(android.app.application.context);      } } 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -