Asked  10 Months ago    Answers:  5   Viewed   194 times

I have implemented Job scheduler in my project and it works fine in the case if the app is in background or if the app is killed. But it is not working if the device is rebooted. I have included

     JobInfo.Builder mBuilder = new JobInfo.Builder(TASK_ID, mComponentName);

in my builder and

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

in application manifest file.This is how I have added my service to manifest

        android:permission="android.permission.BIND_JOB_SERVICE" />

Is there anything else to be included?

Thanks in advance



Register a BroadCastReciever for detecting BOOT_COMPLETED.

<receiver android:name="com.example.startuptest.StartUpBootReceiver">
    <action android:name="android.intent.action.BOOT_COMPLETED" />

And in your BroadcastReceiver:

public class StartUpBootReceiver extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {

    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
        Log.d("startuptest", "StartUpBootReceiver BOOT_COMPLETED");

Once a user runs any activity in your app once, you will receive the BOOT_COMPLETED broadcast after all future boots.

Thursday, August 12, 2021

Follow the pattern Mark Murphy provides with the WakefulIntentService. I would suggest picking up his books, not only for the detailed explanation of this class and example he includes in one of them, but for the other wealth of information you'll find in them.

I just recently implemented this pattern for my main app and this class works like a charm.

Friday, July 16, 2021

Go to your project folder. Open ProjectName folder.

In file Your_Project_name.iml add

<option name="APK_PATH" value="/build/apk/your_app_name-debug-unaligned.apk" />


<option name="APK_PATH" value="/build/outputs/apk/your_app_name-debug-unaligned.apk"/>

In new versions of Android studio

Wednesday, July 28, 2021

I usually bind my service from the Application class and have some kind of controller class (like a "mediator" I guess...not sure how all these patterns are named) scoped in the application that handles communications between services and whatever the active Activity is.

This would involve writing your own Application class and telling the Manifest to use this one. I went into more detail on this process in a previous thread:

More efficient way of updating UI from Service than intents?

You could keep track of the "currently active" Activity by sending the Application class a reference to itself in onResume (also explained in the example above). This can be accomplished by deriving your Activities from a common base class that has a way of getting your Application class (casting from getApplicationContext), and in this base class' onResume, send a ref of itself to the application. Then, you can register activities by name with your DataServiceController, for example, and send messages to the current Activity only if it's registered with the Controller to receive them.

Thursday, July 29, 2021

Unfortunately Instant Apps is not yet available in India. That means, Instant Apps features are by default turned off on the real devices, including in development environment. See the list of supported countries here:

We are working on this issue and will provide an update in a few weeks. In the mean time, please use emulators for you development.

Saturday, August 7, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :