Android 8.0 - Job Intent Service does not run application on bootup
Initially I had Android 7.0 and didn't have any issues using a BroadcastReceiver
and service. However with changes to Android 8.0. I needed to switch to a JobIntentService
so my application can run on bootup.
I have tried migrating my code to match the JobIntentService
but nothing is happening on bootup.
I am unsure whether the reason is because of my service class or my BroadcastReceiver
class.
AndroidManifest.xml
<service android:name=".backgroundService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
backgroundService.java
public class backgroundService extends JobIntentService {
public static final int JOB_ID = 0x01;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, backgroundService.class, JOB_ID, work);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
Intent dialogIntent = new Intent(this, Home.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}
}
startOnBoot.java
public class startOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.i("In" , "getAction() - Boot");
backgroundService.enqueueWork(context, intent);
}
else
Log.i("No" , "Boot");
}
}
So I am trying to essentially start the Home.class
on bootup.
java

add a comment |
Initially I had Android 7.0 and didn't have any issues using a BroadcastReceiver
and service. However with changes to Android 8.0. I needed to switch to a JobIntentService
so my application can run on bootup.
I have tried migrating my code to match the JobIntentService
but nothing is happening on bootup.
I am unsure whether the reason is because of my service class or my BroadcastReceiver
class.
AndroidManifest.xml
<service android:name=".backgroundService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
backgroundService.java
public class backgroundService extends JobIntentService {
public static final int JOB_ID = 0x01;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, backgroundService.class, JOB_ID, work);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
Intent dialogIntent = new Intent(this, Home.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}
}
startOnBoot.java
public class startOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.i("In" , "getAction() - Boot");
backgroundService.enqueueWork(context, intent);
}
else
Log.i("No" , "Boot");
}
}
So I am trying to essentially start the Home.class
on bootup.
java

Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
I thinkACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…
– Rockey
Jan 2 at 14:52
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07
add a comment |
Initially I had Android 7.0 and didn't have any issues using a BroadcastReceiver
and service. However with changes to Android 8.0. I needed to switch to a JobIntentService
so my application can run on bootup.
I have tried migrating my code to match the JobIntentService
but nothing is happening on bootup.
I am unsure whether the reason is because of my service class or my BroadcastReceiver
class.
AndroidManifest.xml
<service android:name=".backgroundService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
backgroundService.java
public class backgroundService extends JobIntentService {
public static final int JOB_ID = 0x01;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, backgroundService.class, JOB_ID, work);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
Intent dialogIntent = new Intent(this, Home.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}
}
startOnBoot.java
public class startOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.i("In" , "getAction() - Boot");
backgroundService.enqueueWork(context, intent);
}
else
Log.i("No" , "Boot");
}
}
So I am trying to essentially start the Home.class
on bootup.
java

Initially I had Android 7.0 and didn't have any issues using a BroadcastReceiver
and service. However with changes to Android 8.0. I needed to switch to a JobIntentService
so my application can run on bootup.
I have tried migrating my code to match the JobIntentService
but nothing is happening on bootup.
I am unsure whether the reason is because of my service class or my BroadcastReceiver
class.
AndroidManifest.xml
<service android:name=".backgroundService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
backgroundService.java
public class backgroundService extends JobIntentService {
public static final int JOB_ID = 0x01;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, backgroundService.class, JOB_ID, work);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
Intent dialogIntent = new Intent(this, Home.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
}
}
startOnBoot.java
public class startOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.i("In" , "getAction() - Boot");
backgroundService.enqueueWork(context, intent);
}
else
Log.i("No" , "Boot");
}
}
So I am trying to essentially start the Home.class
on bootup.
java

java

edited Jan 2 at 15:06
Rockey
297515
297515
asked Jan 2 at 14:42
godlypythongodlypython
778
778
Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
I thinkACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…
– Rockey
Jan 2 at 14:52
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07
add a comment |
Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
I thinkACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…
– Rockey
Jan 2 at 14:52
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07
Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
I think
ACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…– Rockey
Jan 2 at 14:52
I think
ACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…– Rockey
Jan 2 at 14:52
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07
add a comment |
1 Answer
1
active
oldest
votes
I tried it and it could run normally. You could check three tips below.
1.Check whether you have declared RECEIVE_BOOT_COMPLETED
permission or not.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2.Check whether you have declared the receiver with BOOT_COMPLETED
action.
<receiver android:name=".startOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
3.Remove Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
in your service or toast it in main thread. Otherwise it gives you the error java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008295%2fandroid-8-0-job-intent-service-does-not-run-application-on-bootup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I tried it and it could run normally. You could check three tips below.
1.Check whether you have declared RECEIVE_BOOT_COMPLETED
permission or not.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2.Check whether you have declared the receiver with BOOT_COMPLETED
action.
<receiver android:name=".startOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
3.Remove Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
in your service or toast it in main thread. Otherwise it gives you the error java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
.
add a comment |
I tried it and it could run normally. You could check three tips below.
1.Check whether you have declared RECEIVE_BOOT_COMPLETED
permission or not.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2.Check whether you have declared the receiver with BOOT_COMPLETED
action.
<receiver android:name=".startOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
3.Remove Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
in your service or toast it in main thread. Otherwise it gives you the error java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
.
add a comment |
I tried it and it could run normally. You could check three tips below.
1.Check whether you have declared RECEIVE_BOOT_COMPLETED
permission or not.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2.Check whether you have declared the receiver with BOOT_COMPLETED
action.
<receiver android:name=".startOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
3.Remove Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
in your service or toast it in main thread. Otherwise it gives you the error java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
.
I tried it and it could run normally. You could check three tips below.
1.Check whether you have declared RECEIVE_BOOT_COMPLETED
permission or not.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2.Check whether you have declared the receiver with BOOT_COMPLETED
action.
<receiver android:name=".startOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
3.Remove Toast.makeText(this, "Application and Service Started", Toast.LENGTH_LONG).show();
in your service or toast it in main thread. Otherwise it gives you the error java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
.
answered Jan 2 at 15:51
wolfhanwolfhan
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008295%2fandroid-8-0-job-intent-service-does-not-run-application-on-bootup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Take a loot at stackoverflow.com/questions/6391902/…
– Rockey
Jan 2 at 14:44
This doesn't help because with android 8.0 you cannot use implicit broadcast receivers so I am trying to use a job intent service. The link doesn't provide any sort of help?
– godlypython
Jan 2 at 14:47
I think
ACTION_BOOT_COMPLETED
is still accepted on Android 8 stackoverflow.com/questions/45981888/…– Rockey
Jan 2 at 14:52
Well..I have included this in my manifest as well. Still no luck. Not sure what the issue is.
– godlypython
Jan 2 at 15:07