gpt4 book ai didi

android - 如何从启动器中隐藏 Android 应用程序

转载 作者:太空狗 更新时间:2023-10-29 15:52:38 24 4
gpt4 key购买 nike

我想从启动器中隐藏我的 Android 应用程序,但能够从另一个应用程序中调用它。我不知道要从 android list 中删除什么。

已经尝试删除...

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

...但是当从另一个应用程序调用时它不会打开。

这就是我所说的隐藏

        Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("org.xbmc.xbmc");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);

} catch (PackageManager.NameNotFoundException e) {

这是 list 的顶部

  xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_TASKS" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:hasCode="true" android:debuggable="true">
<activity android:theme="@*android:style/Theme.NoTitleBar.Fullscreen" android:name=".Splash" android:finishOnTaskLaunch="true" android:launchMode="singleInstance" android:screenOrientation="sensorLandscape" android:configChanges="touchscreen|keyboard|keyboardHidden|navigation|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

最佳答案

您需要从 AndroidManifest.xml 中删除以下行:

<category android:name="android.intent.category.LAUNCHER"/>

这将从默认启动器中删除该应用程序。但是,您还需要添加以下行,以便您的 BroadcastReceiver没有被完全忽略:

<category android:name="android.intent.category.DEFAULT"/>

您不应该删除下面的行 - 它用于指定哪个 Activity应在您的应用打开时首先启动:

<action android:name="android.intent.action.MAIN"/>

编辑

为了从另一个应用程序启动上面讨论的应用程序,您不能使用问题中显示的调用。您正在尝试通过创建 Intent 打开应用程序与 CATEGORY_LAUNCHER标记 ( i.addCategory(Intent.CATEGORY_LAUNCHER) ) 当您从 AndroidManifest.xml 中明确删除以下行时文件:

<category android:name="android.intent.category.LAUNCHER" />

上面一行的缺失意味着您尝试调用的应用程序将忽略启动 Intent .为了启动您的应用程序,您需要对另一个 Intent 采取行动.这是一个示例,显示如何通过响应 SMS Intent 打开不包含启动 Intent 过滤器的应用程序。 : How to launch an Android app without "android.intent.category.LAUNCHER"

您选择使用哪个 Intent 取决于您 - 只需确保将其添加到您的 AndroidManifest.xml文件。

关于android - 如何从启动器中隐藏 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27990832/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com