9

I had a discussion with a friend and he told me that some applications can be installed on android without any activity or icon showed in menu. Because i'm studying android too i was surprised because i never heard of that.

App's name is showed in "Manage Applications" section and its easy to uninstall it.

So now i'm asking as programmer. How is possible(if it is) to install that kind of application? (with no activity or launcher ).

rootpanthera
  • 2,731
  • 10
  • 33
  • 65

3 Answers3

11

Just remove all of the following intent filters from your manifest:

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

Keep in mind though that from Android 3.1 onwards, your app will not receive any broadcasts, or be listed in any other places where an intent filter would make it available (like in the share menu) if the user hasn't manually opened your app UI (main Activity) at least once from the launcher.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
5

There is another way that works even on Android3.1+ .You can not disable the icon itself, but you can disable one component of an application. So disabling the applications launcher activity will result its icon to be removed from launcher.

The code to do this is simple:

ComponentName componentToDisable =
  new ComponentName("com.helloandroid.apptodisable",
  "com.helloandroid.apptodisable.LauncherActivity");

getPackageManager().setComponentEnabledSetting(
  componentToDisable,
  PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
  PackageManager.DONT_KILL_APP);

There is a few things to know about this solution:

1-the disabled component will not be launchable in any way

2-other non disabled activities will be launchable from other applications

3-an application can only disable its own component. There is a permission "android.permission.CHANGE_COMPONENT_ENABLED_STATE", but it wont work, 3rd party plications can not have this permission

4-the icon will only disapper when the launcher is restarted, so likely on next phone reboot, forcing the launcher to restart is not recommended

In this way,App must be run atleast on time.

Reference:

Removing an app icon from launcher

hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
  • I disagree with point 1 and 4. You can create a receiver (launched from the dialer ex: *#777#) that can be used as "proxy". It's function is to enable and open the MainActivity. I've test this on 4.2. – Pedro Lobito Jul 28 '13 at 03:54
  • @Tuga Thank you for your reply.Do you can explain more details,please? – hasanghaforian Sep 09 '13 at 14:27
2

Yeah this kind of application is possible. You have to create an Application that has no Launcher Activity in the Manifest file.

For eg:- You can register a Broadcast for on boot received. So, that when the device boots your application will be called though it doesn't have any UI. You can checkout this one.

NOTE - This type of Application will only work below 3.1.

Community
  • 1
  • 1
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242