0

In my application, I have created a service. Now from my service I want to fire an implicit intent shown below,

        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("tel:" + "2125551212"));
        if (intent.resolveActivity(getPackageManager()) != null) {
            System.out.println("SENDING PHONE");
            startActivity(intent);
        }

code works without any error, in Logcat I can see launch is fired but no effect is there. No application is responding to this implicit intent.

Same code works when I do from Activity, it opens Phone App.

How can I fire implicit intent from Service?

Service is running in Background.

1 Answers1

0

Android has new limitations on launching activities from background components (Service, BroadcastReceiver). This is to prevent users from being bothered by background apps. In general you should use a Notification and let the user decide when and if to open your app.

See this article for more details on the new restrictions:

https://developer.android.com/guide/components/activities/background-starts

David Wasser
  • 93,459
  • 16
  • 209
  • 274