Android obtains desktop applications and android obtains desktops.

Source: Internet
Author: User

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 );}}

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.