0

I want to launch a 3rd party android application in the background. As suggested by this answer: Answer on stack overflow I have used Alarm Manager and a pending Intent. Before launching the intent for the 3rd party app, I set the AlarmManager for 5000ms and I have the intent for my activity in the pending intent. Here's the code:

AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent comeback= new Intent(this,MyActivity.class);
comeback.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
PendingIntent pi=PendingIntent.getActivity(this,1,comeback,0);
am.set(AlarmManager.ELAPSED_REALTIME,5000,pi); 

startActivity(third_party_app_intent);

The code is does not work properly most of the time. It's very unpredicatble. Moreover, it is a very unsophisticated way of doing it.

Does anyone have any better methods? Kindly help.

Community
  • 1
  • 1
Maverick7
  • 1,087
  • 12
  • 22

0 Answers0