简体   繁体   中英

Application without app launcher icon

I know that this is a very old question, but with the new Android API (currently I'm working on API 19+) could we do it?

I can not remove:

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

from manifest file because Android studio will not compile the app:

Default Activity not found

Updated: Thanks all, I have decided to do it programmatically

because Android studio will not compile the app

Yes, it will. Build > Build APK works just fine.

Android Studio will not run the app, because it does know how to run such an app, but that does not prevent you from compiling the app and generating an APK.

Application without app launcher icon

This situation has not changed significantly since Android 3.1. You are welcome to write an app without a launcher icon. Outside of a few specialized scenarios, that app will be useless, as none of its code will ever run.

Nope.This is essential because this will indicate which activity will be displayed first.And I think you can remove android.intent.category.LAUNCHER.

A similar case is discussed in How to launch an Android app without "android.intent.category.LAUNCHER"

You should be able to create an APK from that project. Use menu Build > Build APK or using gradle from command line.

Installing and running on a device from AS is what will fail here since there is nothing to start.

If you want to remove the app from the launcher you could do that programmatically afterwards via a call to setComponentEnabledSetting() on PackageManager .

I'm creating an application that runs only in background. I had this same problem, having to create an activity that did nothing just to execute the finish() method.

So I found this question: ( https://stackoverflow.com/a/16603708/7548147 ), all you have to do (in Android Studio) is Go to RUN -> Edit Configurations... and Launch Option-> Launch: choose nothing option.

After this, you'll be able to delete your code in Mainfest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM