我正在开发一个应用程序,其中安装后需求是隐藏应用程序图标。意味着应用程序图标将永远不会在主屏幕中显示任何位置。我将通过使用简码来启动应用程序。下面的代码隐藏应用程序ico。安装后隐藏应用程序图标
ComponentName componentToDisable = new ComponentName(context, Splash.class);
context.getPackageManager().setComponentEnabledSetting(componentToDisable,PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
但我的问题是
我如何才能安装我的应用程序后拨打上面的代码行。
我将如何确定我的应用程序刚刚安装了。
我已经加入下面播出menifest文件
<receiver android:name=".utilities.InstallApplicationReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>
</receiver>
下面
是我bradcast类
public class InstallApplicationReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase("android.intent.action.PACKAGE_ADDED")) {
ComponentName componentToDisable = new ComponentName(context, Splash.class);
context.getPackageManager().setComponentEnabledSetting(componentToDisable, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
}
但仍然它不是隐藏应用程序图标:(
有一个广播动作称为“ACTION_PACKAGE_ADDED”,这是可用的到应用程序[除了新添加的应用程序_](https://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED)。这意味着这很简单:用户将不得不运行你的应用程序_至少一次为你的代码删除应用程序图标。要么,要么做这两个答案的建议。 –
从主屏幕或从应用程序抽屉隐藏图标? – dipali
来自应用程序抽屉 –