Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing application without icon or activity

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

like image 441
rootpanthera Avatar asked Mar 28 '13 11:03

rootpanthera


People also ask

Can we have application without activity?

Sure! No reason you cannot have an application with only a service. ...and no need to get into AIDL unless you want to. The problem is, how to make the application run. When you create an application with an Activity, you add an Intent filter, in the manifest, that makes the activity startable from the Launcher.

Why is there an unnamed app on my phone?

Unknown apps are installed thru many sources via internet. It shows unwanted notifications on our mobile screen in most cases. But sometimes it might cause security issue since they can even spy our device and may access our storage data.


3 Answers

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.

like image 199
Raghav Sood Avatar answered Nov 06 '22 04:11

Raghav Sood


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

like image 36
hasanghaforian Avatar answered Nov 06 '22 06:11

hasanghaforian


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.

like image 41
Lalit Poptani Avatar answered Nov 06 '22 04:11

Lalit Poptani