Fixed Launcher method in Android system

Source: Internet
Author: User

Fixed Launcher method in Android system

When developing Android systems, you may encounter such a requirement:

Because it is a self-owned brand, it also involves a service push, so we hope that the Launcher can be fixed, the third party can install, but when you press the Home key, you must return the system default Launcher

After analyzing the Home key process, we can find that it is easy to do. I would like to share with you:

Path: frameworks \ base \ policy \ src \ com \ android \ internal \ policy \ impl \ PhoneWindowManager. java

public void init(Context context, IWindowManager windowManager,            WindowManagerFuncs windowManagerFuncs) {....        mHomeIntent =  new Intent(Intent.ACTION_MAIN, null);        mHomeIntent.addCategory(Intent.CATEGORY_HOME);        mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);..}


To:

public void init(Context context, IWindowManager windowManager,            WindowManagerFuncs windowManagerFuncs) {....ComponentName mHomecom = new ComponentName("com.android.launcher3", "com.android.launcher3.Launcher");        mHomeIntent =  new Intent(Intent.ACTION_MAIN, null);        mHomeIntent.addCategory(Intent.CATEGORY_HOME);        mHomeIntent.setComponent(mHomecom);        mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);..}

That is, to add a setComponent condition here, you need to change the ComponentName to what you need.


After verification, it can be done completely

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.