4

On Android 9 and previous versions, OS was keeping the Open by default setting as Some defaults keep if the user makes your app as the default launcher once. Thus, when the application was to become the default launcher for the second time, the system did not ask the user again.

But for Android 10 and 11, if some apps became the default launcher, the system marks the Open by default setting of all other HOME apps as No defaults set.

So the system annoys the user by asking if they want to set the app as the default launcher each time. How can I prevent this?

    val intent = Intent(Intent.ACTION_MAIN)
    intent.addCategory(Intent.CATEGORY_HOME)
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
    applicationContext.startActivity(intent)

Manifest:

  <activity android:name=".LauncherActivity"
        android:launchMode="singleInstance"
        android:stateNotNeeded="true">
        <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>
    </activity>
Perihan Mirkelam
  • 526
  • 1
  • 5
  • 18

0 Answers0