简体   繁体   English

如何从Android桌面隐藏应用程序图标?

[英]How to hide application icon from the Android Desktop?

I defined an application which is only used from my other application. 我定义了一个仅在我的其他应用程序中使用的应用程序。 So I would like to hide the icon of this application, so that the user can't see it on the desktop of his phone (or how do you call the thing where all apps are listed?). 所以我想隐藏这个应用程序的图标,这样用户就无法在手机的桌面上看到它(或者你如何调用列出所有应用程序的东西?)。 My manifest file looks the following way: 我的清单文件看起来如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="xyz.games.pacman.controller"
      android:versionCode="1"
      android:versionName="1.0">

      <uses-permission android:name="android.permission.BLUETOOTH"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".PacmanGame"
                  android:label="@string/app_name"
                  android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="pacman.intent.action.Launch" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

         <receiver android:name="xyz.games.pacman.network.MessageListener">
         <intent-filter>
            <action android:name="xyz.games.pacman.controller.BROADCAST" />
            </intent-filter>
         </receiver>

    </application>
    <uses-sdk android:minSdkVersion="7" />
</manifest> 

I already read this question: 我已经读过这个问题:

How to hide an application icon in Android emulator? 如何在Android模拟器中隐藏应用程序图标?

but if i just remove the line 但如果我只是删除该行

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

in my manifest, the activity isn't working at all (ActivityNotFoundException in the calling activity). 在我的清单中,活动根本不起作用(调用活动中的ActivityNotFoundException)。

Any hints how to solve this problem? 任何提示如何解决这个问题? I already tried android.intent.category.EMBEDDED but this doesn't work too. 我已经尝试过android.intent.category.EMBEDDED,但这也行不通。

In the Internet I found CommonsWare answer http://osdir.com/ml/Android-Developers/2010-06/msg03617.html that it can be done using PackageManager. 在互联网上,我发现CommonsWare可以使用PackageManager来回答http://osdir.com/ml/Android-Developers/2010-06/msg03617.html Unfortunately, it isn't explained how exactly and I couldn't find a solution by browsing the PackageManager API. 不幸的是,没有解释如何通过浏览PackageManager API来找到解决方案。

why would you write an actual (executable) second application that merely exists to do something when it receives sth from another app? 你为什么要编写一个实际的(可执行的)第二个应用程序,当它从另一个应用程序接收某个应用程序时它只是存在?

i'd suggest, you implement this "app" as a service (remote or local). 我建议你将这个“app”实现为服务(远程或本地)。 this service would then run in the background and do stuff for you and there won't be any icons to be displayed on the screen for it... 然后,这项服务将在后台运行并为您完成任务,并且屏幕上不会显示任何图标...

if neccessary, you can implement this service to be remote, meaning it runs in a totally different process then the first app. 如果需要,您可以将此服务实现为远程服务,这意味着它在与第一个应用程序完全不同的过程中运行。 and: you actually can communicate via broadcast intents as you seem to do by now so you won't need to change your first app... 并且:您实际上可以通过广播意图进行通信,就像您现在所做的那样,因此您无需更改第一个应用程序...

You need to create a custom intent filter and then create an intent which uses that filter. 您需要创建自定义意图过滤器,然后创建使用该过滤器的意图。

For example, in my Funky Expenses application external apps can add transactions. 例如,在我的Funky Expenses应用程序中,外部应用程序可以添加事务。 This is achieved by the manifest for Funky Expenses containing 这是通过包含Funky Expenses的清单来实现的

    <activity android:name="com.funkyandroid.banking.android.ExternalEntryActivity">
        <intent-filter>
            <action android:name="com.funkyandroid.action.NEW_TRANSACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

and then external application can access my activity in the following way; 然后外部应用程序可以通过以下方式访问我的活动;

Intent launchIntent = new Intent();
launchIntent.setAction("com.funkyandroid.action.NEW_TRANSACTION");
... code to set parameters to be passed to activity ...
startActivity(launchIntent);

Pay special attention to the setAction call which sets the correct intent. 请特别注意设置正确意图的setAction调用。

Try removing the intent-filter and instead of trying to launch the 2nd activity with the filter lounch directly the activity: 尝试删除intent-filter,而不是尝试直接使用过滤器lounch启动第二个活动:

Intent second = new Intent(context, xyz.games.pacman.controller.PacmanGame.class);
startActivity(second);

您必须删除整个<intent-filter> ,而不仅仅是<category>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从我的启动器Android隐藏应用程序图标 - How To hide application icon from my launcher android 从应用程序列表中隐藏android图标 - Hide android icon from application list 无法从 Android 菜单中隐藏应用程序图标? - Cant hide application icon from the Android Menu? 如何从我的Android应用程序隐藏Android桌面上的其他应用程序快捷方式图标 - How to hide other application Shortcut icons on android desktop from my android application 如何在Android模拟器中隐藏应用程序图标? - How to hide an application icon in Android emulator? 如何在 Android Studio 中添加弹出菜单到 android 桌面上的应用程序图标? - How add in Android Studio a popupmenu to application icon on android desktop? 如何从启动器隐藏应用程序图标并与之交互 - How to hide an application icon from launcher AND interact with it 如何在Ubuntu中为Android Studio Emulator创建应用程序启动器桌面图标? - How to creating an application launcher Desktop icon for Android Studio Emulator in Ubuntu? 我们如何在Android中以编程方式从Drawer / Launcher / Application Manager隐藏图标 - How can we hide icon from Drawer / Launcher / Application Manager programatically in android 在Android手机菜单中隐藏应用程序图标 - hide application icon in menu of android phone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM