Android之快捷卸载第三方应用代码
Android之快捷卸载第三方应用代码
1、需要的权限:
[html] view plaincopyprint?
01.<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
2、获取所有应用:
[java] view plaincopyprint?
01.public List<ResolveInfo> getAllPagckage(Context context)
02.{
03.PackageManager pm = context.getPackageManager();
04.
05.Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
06.mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
07.// 通过查询,获得所有ResolveInfo对象.
08.List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(
09.mainIntent, PackageManager.GET_GIDS); 毕业论文
10.// 调用系统排序,根据name排序
11.Collections.sort(resolveInfoList,
12.new ResolveInfo.DisplayNameComparator(pm));
13.return resolveInfoList;
14.}
public List<ResolveInfo> getAllPagckage(Context context)
{
PackageManager pm = context.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
// 通过查询,获得所有ResolveInfo对象.
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(
mainIntent, PackageManager.GET_GIDS);
// 调用系统排序,根据name排序