Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

manifest - 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?

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

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...