Android determines whether the current interface is a desktop method.
When developing a desktop floating control, you need to check whether the current desktop is used through the service to control the appearance and disappearance of the floating window. The following code is to determine whether the screen is a desktop.
/*** Determine whether the current interface is desktop */private boolean isHome () {ActivityManager mActivityManager = (ActivityManager) getSystemService (Context. ACTIVITY_SERVICE); List <RunningTaskInfo> RRTI = mActivityManager. getRunningTasks (1); return getHomes (). contains (rrps. get (0 ). topActivity. getPackageName ());} /*** get the application package name of the desktop application ** @ return returns a String List containing all Package Names */private List <String> getHomes () {List <String> names = new ArrayList <String> (); PackageManager packageManager = this. getPackageManager (); Intent intent = new Intent (Intent. ACTION_MAIN); intent. addCategory (Intent. CATEGORY_HOME); List <ResolveInfo> resolveInfo = packageManager. queryIntentActivities (intent, PackageManager. MATCH_DEFAULT_ONLY); for (ResolveInfo ri: resolveInfo) {names. add (ri. activityInfo. packageName);} return names ;}
Code snippet used by android to determine whether a desktop shortcut exists
Let's take a look at this: www.javaeye.com/..horcut
How does android determine whether the activity jump interface exists?
Programmers write this Activity on their own. How can you not know whether the Activity exists or not! So there is no need to judge it!