0

Hello Friend I'm working on Launcher Application. for select my launcher as Home app a popup is showing in samsung. by using this code.

 private void launchAppChooser() {
    PackageManager packageManager = getPackageManager();
    // get dummyActivity
    ComponentName componentName = new ComponentName(context, DummyActivity.class);
    // enable dummyActivity (it starts disabled in the manifest.xml)
    packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    // create a new (implicit) intent with MAIN action
    Intent intent = new Intent(Intent.ACTION_MAIN);
    // add HOME category to it
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // launch intent
    startActivity(intent);

    // disable dummyActivity once again
    packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

}

but this code is not working on OPPO and HUAWEI. I'm using following line for showing same popup to select home launcher

startActivity(Intent.createChooser(intent,"Select Launcher App"));

This code is showing popup with launcher Apps but when i clicked on any app its not set as default. Can i open homescreen Activity from setting in OPPO for choosing default launcher like this(please open image). because CM Launcher app is opening this activity Clicke here to open image Now i Want To Open This Activity Programetically. and Need Yours help for doing this.

M Dilawar
  • 11
  • 6

1 Answers1

0

For checking in oppo devices, you have to check if the current default home app package name contains "oppo.launcher".

After that, use this code using it. You can open the default home apps settings in "oppo devices"

Intent intent = new Intent();
intent.setAction(Settings.ACTION_HOME_SETTINGS);
startActivity(intent);

This is an alternative solution for changing the current home app to your launcher app. This intent redirect user to default launcher app list in oppo devices.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263