Skip to content

Commit

Permalink
Add BIND_ALLOW_ACTIVITY_STARTS flag to bindService
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodim committed Feb 27, 2024
1 parent f91db6b commit d4ab511
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.IBinder;

import org.openintents.openpgp.IOpenPgpService2;
Expand Down Expand Up @@ -99,8 +100,14 @@ public void bindToService() {
Intent serviceIntent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
// NOTE: setPackage is very important to restrict the intent to this provider only!
serviceIntent.setPackage(mProviderPackageName);
boolean connect = mApplicationContext.bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
boolean connect;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
connect = mApplicationContext.bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_ALLOW_ACTIVITY_STARTS);
} else {
connect = mApplicationContext.bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
}
if (!connect) {
throw new Exception("bindService() returned false!");
}
Expand Down

0 comments on commit d4ab511

Please sign in to comment.