如何隐藏从Android桌面应用程序的图标? [英] How to hide application icon from the Android Desktop?

查看:109
本文介绍了如何隐藏从Android桌面应用程序的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义它是只从我的其他应用程序使用的应用程序。所以,我想隐藏这个应用程序的图标,使用户无法看到他的手机桌面上(或你怎么骂,所有的应用程序都列出的东西吗?)。我的清单文件如下方式如下:

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:

<一个href="http://stackoverflow.com/questions/1063604/how-to-hide-an-application-icon-in-android-emulator">http://stackoverflow.com/questions/1063604/how-to-hide-an-application-icon-in-android-emulator

但如果我只是删除行

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

在我的清单,该活动不工作(ActivityNotFoundException在调用活动)。

in my manifest, the activity isn't working at all (ActivityNotFoundException in the calling activity).

任何提示怎么解决这个问题呢?我已经尝试过android.intent.category.EMBEDDED但这不工作了。

Any hints how to solve this problem? I already tried android.intent.category.EMBEDDED but this doesn't work too.

在网上我发现CommonsWare答案 http://osdir.com /ml/Android-Developers/2010-06/msg03617.html 的,它可以使用PackageManager来完成。不幸的是,它没有解释到底如何,我无法找到通过浏览PackageManager API的解决方案。

In the Internet I found CommonsWare answer http://osdir.com/ml/Android-Developers/2010-06/msg03617.html that it can be done using PackageManager. Unfortunately, it isn't explained how exactly and I couldn't find a solution by browsing the PackageManager API.

推荐答案

您需要创建一个自定义的意图过滤器,然后创建一个意图,它使用的过滤器。

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. This is achieved by the manifest for Funky Expenses containing

    <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);

要特别注意的setAction调用它设置了正确的意图。

Pay special attention to the setAction call which sets the correct intent.

这篇关于如何隐藏从Android桌面应用程序的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆