diff --git a/app/src/org/commcare/activities/CommCareActivity.java b/app/src/org/commcare/activities/CommCareActivity.java index fe513fd95c..1e492f47ff 100755 --- a/app/src/org/commcare/activities/CommCareActivity.java +++ b/app/src/org/commcare/activities/CommCareActivity.java @@ -9,6 +9,7 @@ import android.content.DialogInterface; import android.content.IntentFilter; import android.graphics.Rect; +import android.os.Build; import android.os.Bundle; import android.text.Spannable; import android.util.DisplayMetrics; @@ -302,7 +303,14 @@ protected void onResume() { if (shouldListenToSyncComplete() && isBackgroundSyncEnabled()) { dataSyncCompleteBroadcastReceiver = new DataSyncCompleteBroadcastReceiver(); - registerReceiver(dataSyncCompleteBroadcastReceiver, new IntentFilter(COMMCARE_DATA_UPDATE_ACTION)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + registerReceiver( + dataSyncCompleteBroadcastReceiver, + new IntentFilter(COMMCARE_DATA_UPDATE_ACTION), Context.RECEIVER_NOT_EXPORTED); + } else { + registerReceiver( + dataSyncCompleteBroadcastReceiver, new IntentFilter(COMMCARE_DATA_UPDATE_ACTION)); + } } } diff --git a/app/src/org/commcare/activities/FormEntryActivity.java b/app/src/org/commcare/activities/FormEntryActivity.java index d7bff64b32..19453dd191 100644 --- a/app/src/org/commcare/activities/FormEntryActivity.java +++ b/app/src/org/commcare/activities/FormEntryActivity.java @@ -297,7 +297,11 @@ public void onReceive(Context context, Intent intent) { IntentFilter filter = new IntentFilter(); filter.addAction(PollSensorAction.XPATH_ERROR_ACTION); filter.addAction(GeoUtils.ACTION_LOCATION_ERROR); - registerReceiver(mLocationServiceIssueReceiver, filter); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + registerReceiver(mLocationServiceIssueReceiver, filter, Context.RECEIVER_NOT_EXPORTED); + } else { + registerReceiver(mLocationServiceIssueReceiver, filter); + } } @Override @@ -997,7 +1001,11 @@ public void onResumeSessionSafe() { reportVideoUsageIfAny(); IntentFilter intentFilter = new IntentFilter(PENGING_SYNC_ALERT_ACTION); - registerReceiver(pendingSyncAlertBroadcastReceiver, intentFilter); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + registerReceiver(pendingSyncAlertBroadcastReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED); + } else { + registerReceiver(pendingSyncAlertBroadcastReceiver, intentFilter); + } // Flag that a background sync shouldn't be triggered when this activity is in the foreground CommCareApplication.instance().setBackgroundSyncSafe(false); diff --git a/app/src/org/commcare/utils/SessionRegistrationHelper.java b/app/src/org/commcare/utils/SessionRegistrationHelper.java index 2603e795e1..2a2b5ba0be 100755 --- a/app/src/org/commcare/utils/SessionRegistrationHelper.java +++ b/app/src/org/commcare/utils/SessionRegistrationHelper.java @@ -5,6 +5,8 @@ import android.content.Intent; import android.content.IntentFilter; import androidx.appcompat.app.AppCompatActivity; + +import android.os.Build; import android.util.Log; import org.commcare.activities.DispatchActivity; @@ -52,7 +54,11 @@ public static boolean handleSessionExpiration(AppCompatActivity activity) { } public static void registerSessionExpirationReceiver(AppCompatActivity activity) { - activity.registerReceiver(userSessionExpiredReceiver, expirationFilter); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + activity.registerReceiver(userSessionExpiredReceiver, expirationFilter, Context.RECEIVER_NOT_EXPORTED); + } else { + activity.registerReceiver(userSessionExpiredReceiver, expirationFilter); + } } /**