0

How can i show alert in any one of running activities of third party app by initializing service (finds and show alert) in mainactivity of third party app and it needs to show my alert in one activity.

Please look at this i think we can do using this.

ArrayList<String> runningactivities = new ArrayList<String>();

ActivityManager activityManager = (ActivityManager)getBaseContext().getSystemService (Context.ACTIVITY_SERVICE); 

List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE); 

    for (int i1 = 0; i1 < services.size(); i1++) { 
        runningactivities.add(0,services.get(i1).topActivity.toString());  
    } 

    if(runningactivities.contains("ComponentInfo{com.app/com.app.main.MyActivity}")==true){
        Toast.makeText(getBaseContext(),"Activity is in foreground, active",1000).show(); 

        alert.show()
    }

please help me how can i achieve this.

Suneel
  • 1
  • 1
  • Please try to rephrase your question in an understandable way. – FD_ Feb 19 '14 at 10:58
  • please read my question again i have changed it. – Suneel Feb 19 '14 at 11:14
  • AlertDialogs are tied to a parent context, which you wouldn't have. You can't just go around adding your own dialogs over other people's apps. That's incredibly intrusive and annoying! Even the very thought of it sounds dodgy. Maybe give a little more context as to your requirement? – laminatefish Feb 20 '14 at 09:47
  • i will get the context by asking other app developer to call method that contains context parameter. – Suneel Feb 20 '14 at 10:01

0 Answers0