Hide an application from Android application list

前端 未结 3 1564
Happy的楠姐
Happy的楠姐 2021-02-14 17:14

Is there any way to hide an application icon from Android applications list ? The application should be downloaded from Market and opened some GUI for configuring my application

相关标签:
3条回答
  • 2021-02-14 17:48

    Thanks for replay. I found a way to hide application icon from application list;

    PackageManager pm = getApplicationContext().getPackageManager();
    pm.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    

    But in time of application reinstalling occurs error "Activity class does not exist" and it is not possible to reinstall application without uninstalling it. .... what's the problem ?

    There is also variant of Launcher Pro. But this is an application. My app should be downloaded from Android Market and there is no guarantee that all users have Launcher Pro. I want programmatically hide application icon from application list. The method with PackageManager works for me ... but there is a problem regarding reinstalling. It is important when you want to update the application from Market.

    0 讨论(0)
  • 2021-02-14 17:57

    I have found a way for this to work when you reinstall the app.

    Add a broadcast receiver with intent filter action android.intent.action.PACKAGE_ADDED.

    In the onReceived method you must activate your disabled component :

    ComponentName componentToEnable = new ComponentName(context, Your_disabled_class.class);
    PackageManager pm = context.getPackageManager();
    pm.setComponentEnabledSetting(componentToEnable, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,                           PackageManager.DONT_KILL_APP);
    

    Complete AndroidManifest.xml for receiver:

    <receiver android:name="PackageChangeReceiver">
    
    <intent-filter>
    <action android:name="android.intent.action.PACKAGE_ADDED"/>
    <action android:name="android.intent.action.PACKAGE_REPLACED"/>
    <action android:name="android.intent.action.PACKAGE_REMOVED"/>
    
    <data android:scheme="package"/>
    
    </intent-filter>
    </receiver>
    
    0 讨论(0)
  • 2021-02-14 17:58

    Removing the launcher category is correct.

    Try adding android.intent.category.DEFAULT to the intent filter to be able to call the activity.

    0 讨论(0)
提交回复
热议问题