user clicks on "facebook" app (for example) 1.My app detects the launch of an app 2.my app confirms it is the "facebook" app 3.my app destroy the facebook app to prevent it from open So please help me to solve this problem
Asked
Active
Viewed 1,952 times
2
-
i don't know if such a broadcast exist for user side of the framework – DevZer0 Aug 22 '13 at 04:51
-
There used to be a way, and it will work on pre- Jelly Bean - monitoring logcat. – IuriiO Aug 22 '13 at 05:06
-
@M-WajeEh, i m not thor. – user1811379 Aug 22 '13 at 05:13
-
@Luriio, when i read logs then if i can detect it is facebook app then how can i destroy or quit the facebook app... – user1811379 Aug 22 '13 at 05:16
2 Answers
1
I believe the only feasible way possible would be the following:
- Create a service the calls getRunningTasks periodically. Note this would not be real time but there is no broadcast when an application is launched and this is pretty bad behavior as far as efficiency depending on how often you want to check.
- Due to limitations of the OS as of 2.2, see How to close another app in Android?, you can probably only close an application through
su
(rooted phone). Otherwise it simply might not be possible.
1
First issue is to detect that a certain app has started. That was dicussed some times before:
Android, Detect when other apps are launched
How to detect when the user launches another app? (Android)
https://stackoverflow.com/questions/16907451/how-to-launch-my-service-when-another-app-is-launched?rq=1
The most promissing answers talk about scanning the logcat.
Seond thing is to destroy another app. Simple answer: Your app cannot destroy another app unless explicitely coded by that other app. You can basically send broadcasts from any application to any broadcast receiver, but it's up to the receiver what happens with the message.