Monday, May 28, 2012

[android-developers] How to create the Receiver for launch application in android

Hi,


I want to enforce enterprise security by restricting the use of some
applications like youtube or gtalk.

My service runs in the background and it should show the home screen
on launch of any of the blacklisted applications.

However, there is no intent for Activity/application launch.

Please let me know how to do this.

I have tried this :

ActivityManager activityManager = (ActivityManager)
this.getSystemService(ACTIVITY_SERVICE);
List<RunningTaskInfo> tasks = activityManager.getRunningTasks(3);

ComponentName componentInfo = tasks.get(0).topActivity;
String pkgName = componentInfo.getPackageName();
if (pkgName.contains("com.google.android.youtube")){

activityManager.killBackgroundProcesses(pkgName);
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);

}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate