Android IntentService won't start on boot -
i have intentservice starts on boot , stays running in background. there no launcher activity, intentservice called broadcast receiver. works on 2.3.4 , 4.0.4 devices not on 4.2.2. maybe broadcast receiver isn't being triggered on device?
manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.xxx" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.read_phone_state" /> <uses-permission android:name="android.permission.receive_boot_completed" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <receiver android:name="br.com.xxx.rastreadorbroadcastreceiver" > <intent-filter> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> <service android:name="br.com.xxx.obtainandpostlocationservice" android:exported="true"> </service> </application> </manifest>
rastreadorbroadcastreceiver:
package br.com.xxx; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; public class rastreadorbroadcastreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { intent startserviceintent = new intent(context, obtainandpostlocationservice.class); context.startservice(startserviceintent); } }
try changing
<receiver android:name="br.com.xxx.rastreadorbroadcastreceiver" >
in
<receiver android:name=".rastreadorbroadcastreceiver" >
Comments
Post a Comment