-1

I have app that after installtion need to be hidden in home menu.
the app is for push notifications only.
I read this but android.intent.action.BOOT_COMPLETED not work.
there I read also Think Twice Code Once answer.
so currently I am searching about way to interact with user at least once after installation without activity or with activity in the way that app icon not appear in home menu. or change reciver or service state immediately after installtion without user interaction

any idea?

thanks!

Yaffa Harari
  • 43
  • 1
  • 6

1 Answers1

0

The app needs to be run manually at least once by the user, otherwise the app will remain in the "stopped state" and you will not receive any broadcast Intents. You will need to have an Activity and that Activity will need to have an entry in the manifest with ACTION=MAIN and CATEGORY=LAUNCHER. What you could do is disable the Activity programmatically after it is launched the first time. This would prevent the Activity from being shown on the HOME screen. Here's an example:

PackageManager pm = getPackageManager(); 
pm.setComponentEnabledSetting(new ComponentName(this, my.packagename.MainActivity.class),
        PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

NOTE: If you do this, and the user "force stops" your app (Android settings->Apps->YourApp->Force Stop) then there will be no way to restart your app other than uninstalling and reinstalling it.

David Wasser
  • 93,459
  • 16
  • 209
  • 274