2hamed
2hamed

Reputation: 9047

How to make your Android app not appear in the app drawer?

I'm developing an application that I don't want it to appear in the app drawer. I wonder how can i achieve that?
To be clear I just want my app to be run only once.

Upvotes: 0

Views: 741

Answers (2)

a fair player
a fair player

Reputation: 11776

you will need to add the following lines to your activity:

ComponentName componentToDisable = new ComponentName("your.app.package",
                              "your.app.package.youractivityname");

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

these lines will make your app not accessible any more and once you reboot your device, the icon will be removed.

hope this helps.

Upvotes: 0

Alex Florescu
Alex Florescu

Reputation: 5151

Going back to my comment, I think a bit of clarification on the problem would help, since it's not quite clear what you're trying to do and why.

What you could do is allow your app to run, but show something else after it ran the first time. So the first time you run it, it will open and run Activity A.

After that happens, update some flag in a stored record (e.g. a Db entry, a conf file). Then, on subsequent runs of the application, have a check in activity A and if the flag is set, show a different screen and don't run whatever it was you ran the first time. Just show a screen that informs the user something relevant wrt what you're trying to achieve.

Does that make sense?

I also think this is a better approach, because as an user I would prefer to have some info of what just happened instead of having your app disappear after I ran it the first time.

Upvotes: 1

Related Questions