I explain what I want my app does:
The user powers on the phone, my service starts and executes his code. The problem is that at the moment the service doesn't start...I can't see logs or toast.
this is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="complic.bevoip">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_REBOOT" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
<service
android:name=".Sip.SipService"
android:enabled="true"
android:exported="true"></service>
<receiver android:name=".Sip.Receiver"
android:process=":remote">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.REBOOT"/>
</intent-filter>
</receiver>
</application>
</manifest>
The broadcastReceiver
public class Receiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Log.d("MIO", "abcde");
Intent i = new Intent(context, MainActivity.class);
context.startService(new Intent(context, SipService.class));
}
}
and the service
public class SipService extends Service {
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
Log.d("BeVoip", "service partito");
startActivity(new Intent(this, MainActivity.class));
return Service.START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service Destroy", Toast.LENGTH_LONG).show();
}
}