2

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

user1811379
  • 385
  • 1
  • 4
  • 12

2 Answers2

1

I believe the only feasible way possible would be the following:

  1. 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.
  2. 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.
Community
  • 1
  • 1
JRomero
  • 4,878
  • 1
  • 27
  • 49
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.

Community
  • 1
  • 1
jboi
  • 11,324
  • 4
  • 36
  • 43