Android Gets the package name and startup class name of all programs and widgets for the phone

Source: Internet
Author: User


The Get widget can be appwidgetmanager to get

List<appwidgetproviderinfo>
Widget=appwidgetmanager.getinstance (context). Getinstalledproviders ();

Get all Appwidgetproviderinfo

for (int i = 0; i < widget.size (); i++) {
Appwidgetproviderinfo Info=widget.get (i);
String Packname=info.provider.getpackagename ();
String Classname=info.provider.getclassname ();

LOG.E ("-------packname", packname);
LOG.E ("-------classname", classname);

}



Getting the package name of the program in the phone is similar to the startup class name and widget.

The application's startup class name, which is added in the Androidmanifest.xml file <activity>

<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>

Filter condition to specify that the class name is the first activity class to start




So let's go get the package name and startup class name of the application:


Intent appintent = new Intent (intent.action_main, NULL);


Appintent.addcategory (Intent.category_launcher);


List<resolveinfo> Resolveinfos = Context (contextual)
. Getpackagemanager (). Queryintentactivities (appintent, 0);

for (int i = 0; i < resolveinfos.size (); i++) {
ResolveInfo ResolveInfo = Resolveinfos.get (i);
String ClassName = resolveInfo.activityInfo.name;
String PackageName = resolveInfo.activityInfo.packageName;

LOG.E ("-------packname", PackageName);
LOG.E ("-------classname", classname);}

That's it.



If it is not clear, the following is attached Deom

NET Disk Http://pan.baidu.com/s/1sj4S5tV


This article is from the "Samuel" blog, make sure to keep this source http://huangsm.blog.51cto.com/8903178/1436708

Related Article

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.