我想允许我的 Android 应用程序的用户在需要时隐藏/取消隐藏它。我已经有了执行隐藏/取消隐藏操作的代码,并且隐藏工作正常。但是现在如何调用 unhide 方法让应用返回呢?我的意思是,如果应用程序被隐藏,那么用户可以在哪里,比如说,“单击一个按钮”来调用该方法以使应用程序取消隐藏?
这是我的隐藏/取消隐藏代码:
// method to hide the app icon
public static void hideAppIcon(final Context context)
{
PackageManager p = context.getPackageManager();
// activity which is first time open in manifest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
ComponentName componentName = new ComponentName(context, SplashActivity.class);
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
// method to unhide the app icon
public static void unhideAppIcon(final Context context)
{
PackageManager p = context.getPackageManager();
// activity which is first time open in manifest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
ComponentName componentName = new ComponentName(context, SplashActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}