Skip to content

Commit

Permalink
Avoid crash on boot for android < 8
Browse files Browse the repository at this point in the history
Pull request 28a9015
  • Loading branch information
federicoiosue committed Jan 12, 2020
1 parent df5b40b commit b8f18a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions omniNotes/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
<uses-permission android:name="com.pushbullet.android.permission.READ_MESSAGING_EXTENSION_DATA" />
<uses-permission android:name="com.pushbullet.android.permission.SEND_MESSAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<uses-feature
android:name="android.hardware.camera"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import it.feio.android.omninotes.BaseActivity;
Expand All @@ -29,13 +30,20 @@
import it.feio.android.omninotes.utils.ReminderHelper;
import java.util.List;


/**
* Verify version code and add wake lock in manifest is important to avoid crash
*/
public class AlarmRestoreOnRebootService extends JobIntentService {

public static final int JOB_ID = 0x01;

public static void enqueueWork (Context context, Intent work) {
enqueueWork(context, AlarmRestoreOnRebootService.class, JOB_ID, work);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
enqueueWork(context, AlarmRestoreOnRebootService.class, JOB_ID, work);
} else {
Intent jobIntent = new Intent(context, AlarmRestoreOnRebootService.class);
context.startService(jobIntent);
}
}

@Override
Expand Down

0 comments on commit b8f18a4

Please sign in to comment.