获取 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
android 获取手机的所有程序和widget的包名和启动类名,布布扣,bubuko.com