Android Starting Service at Boot Time , How to restart service class after device Reboot?
Create a BroadcastReceiver
and register it to receive ACTION_BOOT_COMPLETED. You also need RECEIVE_BOOT_COMPLETED permission.
Read: Listening For and Broadcasting Global Messages, and Setting Alarms
Restart service on device reboot
Now I fixed in on my own it was easier then i thought
public class BootCompletedIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i=new Intent(context, YourClass.class);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
context.startForegroundService(i);
}
else {
context.startService(i);
}
}
Related Topics
Android Camera Intent: How to Get Full Sized Photo
How to Get the Absolute Coordinates of a View
How to Use Speech Recognition Without the Annoying Dialog in Android Phones
Android Writing Logs to Text File
How to Have Placeholders in Strings.Xml for Runtime Values
Android - Set Max Length of Logcat Messages
How to Add Stacktrace or Debug Option When Building Android Studio Project
How to Make a Specific Text on Textview Bold
Android Recyclerview Gridlayoutmanager Column Spacing
Viewpager.Setoffscreenpagelimit(0) Doesn't Work as Expected
Android: How to Check If a View Inside of Scrollview Is Visible
Android Spinner: Get the Selected Item Change Event
Error Type 3 Error: Activity Class {} Does Not Exist
Android API 21 Toolbar Padding
What Does Layoutinflater in Android Do