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 determine whether the desktop method
/** * Determine 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 the app package name for apps that belong to the desktop * * @return returns a list of strings that contain all the 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; }