How can I call (use ACTION_CALL) in fore ground service, it works completely fine when app is opened but not in background
new Handler().post(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:9325979573" ));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
startActivity(intent);
}
});
}
i have given permission but yet... idk what to do...
On modern Android you cannot launch an activity from a background. See https://developer.android.com/guide/components/activities/background-starts. Notice that for the purposes of starting activities, foreground services do NOT count as in the foreground, they're still counted as in the background, as per that documentation.