in the development of the desktop floating control, you need to view the current desktop through the service, so as to control the appearance and disappearance of the floating window, the following code is to infer whether the desktop method
/** * Infer If the current interface is desktop */private Boolean ishome () {Activitymanager Mactivitymanager = (activitymana GER) Getsystemservice (Context.activity_service); list<runningtaskinfo> RTI = mactivitymanager.getrunningtasks (1); Return Gethomes (). Contains (Rti.get (0). Topactivity.getpackagename ()); }/** * Get app package name for app belonging to desktop * * @return returns a list of strings that include 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_d EFAULT_ONLY); for (ResolveInfo ri:resolveinfo) {names.add (ri.activityInfo.packageName); } return names; }