如何让用户按需取消隐藏应用程序图标

问题描述 投票:0回答:1

我想让我的 Android 应用程序的用户在需要时隐藏/取消隐藏它。 我已经有了执行隐藏/取消隐藏操作的代码,并且隐藏工作正常。 但是现在如何调用取消隐藏方法让应用程序返回呢? 我的意思是,如果应用程序是隐藏的,比方说,用户可以在哪里“单击一个按钮”来调用使应用程序取消隐藏的方法?

这是我的隐藏/取消隐藏代码:

// 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);
    }
android icons hide
1个回答
0
投票

这是我从另一个应用程序中学到的一种方法。不要“隐藏”图标,而是更改应用程序的图标和标签。将应用程序伪装成一些内置应用程序,如“设置”或“计算器”。

另一个解决方案(可能更接近您的需要)是在您的应用程序中添加一个意图过滤器,检测电话之类的东西。如果用户拨打某个号码,您将取消隐藏您的应用程序。

有关更多信息,请参阅this

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.