Android hidden application
Asked Answered
P

4

25

I'm writing a (legal) spy program. I want to make this program hidden on the launcher (so that no icon is shown). I tried to remove <category android:name="android.intent.category.LAUNCHER" /> line from AndroidManifest.xml, but then the user can't launch the application in first start mode (configuration). Who have any ideas ?

How can I do it?

Peripatetic answered 7/1, 2013 at 21:55 Comment(0)
B
37

You need to make your app into a service. Here is Androids take on creating services components:

http://developer.android.com/guide/components/services.html

Found this as well on MobiWare:

When you want to track the usage of the mobile or gather some data without user knowledge,this might help you.

Step1: Create an application with No icon. Normally,an activity is declared as follows in manifest.

     <activity
        android:label="@string/app_name"
        android:name="org.security.tracker.Tracker-activity" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

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

Remove the Category TAG ,you wont get app icon anymore. Now,you don't need activity anymore. so remove this segment. BUt you might think,how the app will run without any trigger or what is the starting point of the application. This is the solution.

<!-- Start the Service if applicable on boot -->
    <receiver android:name="org.security.tracker.ServiceStarter" >
        <intent-filter >
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

This triggers your code that written in Receiver there by you can run service to implement your thoughts.

 <service android:name="org.security.tracker.serviceCode" />

You need to add this permission,

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

Your code runs when the phone reboots only.

Step 2. Write your code

On Reboot,the recevier will fire ,there you can start your service.

class ServiceStarter extends BroadcastReceiver {

@Override
public void onReceive(Context _context, Intent _intent) {

    Intent i = new Intent("com.prac.test.MyPersistingService");
    i.setClass(_context, ServiceCode.class);
    _context.startService(i);
  }

 }
Brauer answered 7/1, 2013 at 22:5 Comment(4)
Android studio won't compile if there no LAUNCHER category in androidmanifestDyadic
How the service code will execute ,if you not able to launch the application ,Android studio only won't get compile first timeOrelia
Not receiving any call in BroadcastReceiver until I start activity onceNegrophobe
Hey I am trying to follow your example - can you clarify what MyPersistingService and ServiceCode is - I am having trouble understanding how they are implmented.Maragretmarala
D
5

You can remove the <category android:name="android.intent.category.LAUNCHER"/> from the AndroidManifest.xml file.

But remember to add <category android:name="android.intent.category.LEANBACK_LAUNCHER"/> so that Android studio will be able to compile your app (yet hidden from launcher) :) :D

Donor answered 31/7, 2017 at 10:5 Comment(0)
B
3

remove

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

from the manifest file

Bettinabettine answered 7/1, 2013 at 22:9 Comment(5)
@AmitApollo, No Need to create a service.Bettinabettine
How will the app ever be started?Zosema
@Zosema I'm not an expert but maybe it is a broadcast receiver?Cypro
@RicardoCristianRamirez : You can't start any Android application component unless the user has "launched" the app. That includes Services and BroadcastReceivers - it has been that way for quite a few versions of Android for security reasons.Zosema
It will not work , android studio won't compile only.it's will say"Default activity not found".Orelia
C
-2

The app can be hidden programmatically, Below is the code which will hide the app from the Launcher menu. this works fine android 10 as well

// App will be hidden when this method will be called from menu
private fun hideApp() {

    val packageManager =packageManager
    val name =ComponentName(this,MainActivity::class.java)
    packageManager.setComponentEnabledSetting(name,PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP)
    Log.d("TAG", "hideApp: success")
}

For more information, you can check this link https://developer.android.com/reference/android/content/pm/PackageManager#setComponentEnabledSetting(android.content.ComponentName,%20int,%20int)

Conure answered 3/10, 2020 at 14:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.