Android - creating custom launcher

后端 未结 2 561
温柔的废话
温柔的废话 2020-12-07 23:22

I am intending to develop custom Launcher for Android phone. I have searched web, but I haven\'t found any valuable information regarding creating \"launcher\" project. What

2条回答
  •  太阳男子
    2020-12-08 00:11

    I saw this thread a while ago, before creating my own launcher.
    Here are some crucial things I learned:


    Declaring your app to be a launcher

    David already mentioned the piece of code that determines your app as a launcher:

    
    

    Add this as an intent-filter to the activity your launcher will use for the home screen (in AndroidManifest.xml).

    Launcher Issues

    As a launcher will run all the time, you need to understand the activity livecycle to prevent issues (like this one).

    If you want users (and yourself) to be able to constantly user the app (that's what you usually do with launchers), make sure it never crashes. In the case of a crash users will be taken back to the devices default launcher or other installed ones.

    In short: Launchers are expected to be reliable.

    Common launcher functions (users usually expect those)

    1) A list of apps / appdrawer

    From which all apps can be launched or modified. You can use packageManager to list the apps.

    As generating such a list may take a while, I suggest you to do it asynchronously and save the list somewhere to speed everything up (which also is expected from launchers ^^)

    2) Some settings to change the launcher

    I had some users stuck in my launcher before implementing those ^^

    You can open the devices launcher settings like this (in Kotlin):

    // working in APIs newer than Lollipop
    val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
    startActivity(callHomeSettingIntent)
    

    Bonus) An in-app tutorial

    This may be useful if you have some features in your app that are not trivial, ways of launching apps that users don't know from other apps.

    It also gets you way less messages from users asking how to interact with your software.


    Resources:

    • The GitHub of the minimal launcher I created may be helpful: finnmglas/Launcher

提交回复
热议问题