1

我无法在android中隐藏已安装的应用程序..我使用了下面的代码..

disableDrawerIcon("com.androglobe.androrec");

public void disableDrawerIcon(String component) {
    try {
        PackageManager pm = this.getPackageManager();
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);
        Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));
        ComponentName componentName = null;
        for (ResolveInfo temp : appList) {  

            if (temp.activityInfo.packageName.equals(component)) {

                componentName = new ComponentName(component,
                        temp.activityInfo.name);

                Log.v(TAG, ""+temp.activityInfo.name);
            }

        }

        if (componentName != null) {


        pm.setComponentEnabledSetting(componentName,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
        Log.v(TAG, "Icon disabled");

        }
    } catch(Exception e) {
        e.printStackTrace();
        Log.v(TAG, "ERROR");
    }
    }

所以请帮助我....提前谢谢...

4

2 回答 2

3

如果您不想在您的应用程序上使用启动器图标,请不要将“LAUNCHER”类别放在“AndroidManifest.xml”文件的任何活动中。类别如下所示:

<category android:name="android.intent.category.LAUNCHER" />
于 2013-05-03T15:18:59.740 回答
0

消除

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

从所有活动的清单中。

于 2013-05-03T15:19:45.563 回答