I have an Android Service that is going to run on background, without user interaction. I would like it to starts on Android boot. It that possible? How can I debug it, since there's no LAUNCHER?
This is my AndroidManifest.xml, according to my searches:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" >
<service android:name=".MyService" android:exported="true" android:enabled="true" />
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
This is MyReceiver:
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent myService = new Intent(context, MyService.class);
context.startService(myService);
}
}
And MyService:
public class MyService extends IntentService {
public MyService(String name) {
super(name);
}
@Override
protected void onHandleIntent(Intent intent) {
/* stuff */
}
}
The point is it never reaches breakpoints at MyReceiver or MyService. Any ideas?