The function below is called in the service. When the condition is fulfill then the intent is calling to do something.
I used mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
to execute the intent from the service but in android 10 the intent is not working.
Can anybody help me to solve this problem?
public void playAudio(){
if(mp != null && !mp.isPlaying()){
//dont want to pick up phone audio
claps++;
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
//OverviewFragment.refresh(getApplicationContext());
System.out.println("yay" + claps);
Log.e("claps", String.valueOf(claps));
//Toast.makeText(AnotherService.this, "In background thread", Toast.LENGTH_SHORT).show();
Toast.makeText(AnotherService.this, ""+ claps, Toast.LENGTH_SHORT).show();
}
});
}
if(mp != null && !mp.isPlaying() && claps >= MainActivity.w){
mp.start();
Intent mainIntent = new Intent(AnotherService.this, StopAlarmActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mainIntent);
claps = 0;
}
//modifyText();
}