how can i open an Activity in the Background from my Service?
The App is running in background and an Intent Brodcast that triggers the start of an Activity within my app.
I tried it on an Android 8.1 Device and it works fine but on the Andrid 11 Device it wont work.
public void StartRead(){
Intent i = new Intent(this, TestActivity.class);
startActivity(i);
}
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(VariableStorage.getInstance().BRODCAST_READ)){
//Start RFID Activity
StartRead();
}else if(intent.getAction().equals(VariableStorage.getInstance().BRODCAST_DECODEVDA)){
//Decode VDA55
}
}
};
AndroidManifest.xml :
<activity
android:name=".TestActivity"
android:exported="true"
android:enabled="true"/>
My Service is a normal ForegroundService.
how can i open an Activity in the Background from my Service?
You can't.
The reason and your options is explained in the documentation: