Android obtains desktop applications and android obtains desktops.
First, before reading this blog, you can look at this blog, http://blog.csdn.net/harryweasley/article/details/50057707
This section describes two methods to obtain application information: packageInfo and ResolveInfo. A bug occurs when packageInfo is used to obtain application information, that is, if the application has multiple icons and names, only the first one is displayed by default. So now I use ResolveInfo to get user information.
For more information about multiple icons and names, see this article. Http://blog.csdn.net/harryweasley/article/details/48051565
See:
There are four applications with the same package name, but the icons and names are different.
In fact, it is relatively simple to obtain information about all the applications on the desktop. The following is the main code. At the end of the article, resources will be posted.
Package com. example. getlauncherapp; import java. util. list; import android. app. activity; import android. content. intent; import android. content. pm. packageManager; import android. content. pm. resolveInfo; import android. OS. bundle; import android. view. menu; import android. view. menuItem; import android. widget. listView; public class MainActivity extends Activity {private ListView myListView; private List <ResolveInfo> resolveInfoList; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); myListView = (ListView) findViewById (R. id. listView); getLauncherApp (); MyBaseAdapter adapter = new MyBaseAdapter (this, resolveInfoList); myListView. setAdapter (adapter);}/*** get the desktop application */private void getLauncherApp () {// start of the desktop application must include ACTION_MAIN and CATEGORY_HOME In the INTENT. intent intent = new Intent (); intent. addCategory (Intent. CATEGORY_LAUNCHER); intent. setAction (Intent. ACTION_MAIN); PackageManager manager = getPackageManager (); resolveInfoList = manager. queryIntentActivities (intent, 0 );}}