I want get boot complete event because I want to call service after device is restarted. and I not got any solution. and I want to call service implicitly without open my app. My service working fine if at least once app open manually(when service calling from main activity).
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.bitsend.swipescreen"
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".ScreenStatusService"></service>
<receiver
android:name=".BootReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
BootReceiver.java
public class BootReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
// Your code to execute when Boot Completd
String action =intent.getAction();
if(action.equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent service = new Intent(context, ScreenStatusService.class);
context.startService(service);
}
}
}