0

i want to know if i can set my app as default launcher when i want it to be (not a fixed feature) , because i'm developing babies game ,and i want to put lock buttons as an option so i can handle home button when pressed. and when the app is finished return the original launcher. i searched about it in the internet but all i found is to set it as fixed feature in manifest file like this:

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

So any help

thanx

Khalil Tam
  • 441
  • 1
  • 3
  • 13

1 Answers1

0

i want to know if i can set my app as default launcher when i want it to be

No, you cannot. The user can elect to make your app be their default home screen. Malware authors cannot attack users by forcibly replacing their home screen with another implementation.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • thank you, and sorry for mess understand , i mean i want the user to select it to be the default home screen , but i want to make this feature is optional (can be enabled & disabled) – Khalil Tam Apr 23 '15 at 23:03
  • @KhalilTam: You can use `PackageManager` and `setComponentEnabledSetting()` to enable and disable your activity that has the `MAIN`/`HOME` ``. When it is enabled, the user will get a chooser when they next press the HOME button, and they can elect to choose to use your home screen. – CommonsWare Apr 23 '15 at 23:07
  • the activity that has is my main activity ,so how can i disable it ? because i tried but the app was crashed – Khalil Tam Apr 24 '15 at 00:45
  • @KhalilTam: You could try moving the `` for `HOME` off of that activity and onto an `` that points to the activity. Then, in theory, you could enable and disable the alias. I do not recall having tried this, though. – CommonsWare Apr 24 '15 at 00:49
  • i was trying something similar , by making new activity to handle , the main activity , and starting activity (for loading stuff) (which it's extend from main) and it's the default launch activity of my app. and for Now everything is OK! and it's worked , thank you – Khalil Tam Apr 24 '15 at 01:09