获取 widget可以 AppWidgetManager 来获取
List<AppWidgetProviderInfo>
widget=AppWidgetManager.getInstance(Context(上下文)).getInstalledProviders();
得到所有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);
}
获取手机里的所以程序的包名和启动类名 和widget类似.
应用程序的启动类名,即在AndroidManifest.xml文件中<activity>中加了
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
的过滤条件来,指定那个类名是启动的第一个activity类
所以我们去获取应用程序的包名和启动类名:
Intent AppIntent = new Intent(Intent.ACTION_MAIN, null);
AppIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfos = Context(上下文)
.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);}
这样就可以了..!
如果还不是很清楚,下面附上deom
网盘 http://pan.baidu.com/s/1sj4S5tV
本文出自 “Samuel” 博客,请务必保留此出处http://huangsm.blog.51cto.com/8903178/1436708