Skip to content

Commit be90aba

Browse files
fix so that the job service will not run if there is no internet connection (possibly causing ANR). Also, start job right away so for instance events are flushed faster (another customer request (#295)
1 parent 51646b9 commit be90aba

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

shared/src/main/java/com/optimizely/ab/android/shared/ServiceScheduler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ public static void startService(Context context, Integer jobId, Intent intent) {
270270
JobInfo jobInfo = new JobInfo.Builder(jobId,
271271
new ComponentName(context, JobWorkService.class))
272272
// schedule it to run any time between 1 - 5 minutes
273-
.setMinimumLatency(JobWorkService.ONE_MINUTE)
273+
.setMinimumLatency(0)
274+
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
274275
.setOverrideDeadline(5 * JobWorkService.ONE_MINUTE)
275276
.build();
276277
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);

test-app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
-->
1919

2020
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
21-
package="com.optimizely.ab.android.test_app">
21+
xmlns:tools="http://schemas.android.com/tools"
22+
package="com.optimizely.ab.android.test_app">
2223

2324
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
2425
<uses-permission android:name="android.permission.WAKE_LOCK" />
@@ -31,7 +32,8 @@
3132
android:icon="@mipmap/ic_launcher"
3233
android:label="@string/app_name"
3334
android:supportsRtl="true"
34-
android:theme="@style/AppTheme">
35+
android:theme="@style/AppTheme"
36+
tools:ignore="GoogleAppIndexingWarning">
3537
<service
3638
android:name=".NotificationService"
3739
android:exported="false" />

0 commit comments

Comments
 (0)