Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use MTK to set the default Desktop in Android7.0

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use MTK to set the default desktop in Android 7.0". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian to study and learn "how to use MTK to set the default desktop in Android 7.0" together.

1. Find the file that installs the app.

frameworks\base\services\core\java\com\android\server\pm\PackageManagerService.java try { PackageParser.Package newPackage = scanPackageTracedLI(pkg, policyFlags, scanFlags, System.currentTimeMillis(), user); updateSettingsLI(newPackage, installerPackageName, null, res, user); if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) { prepareAppDataAfterInstallLIF(newPackage); Log.d("yh", "pkgName " +pkgName); //Package name of Dim Sum Desktop used here due to client application confidentiality---com.dianxinos.dxhome if (pkgName.equals("com.dianxinos.dxhome")){ //Send Broadcast Intent = new Intent("android.intent.action.UPDATE_LANUCHER_APPS"); mContext.sendBroadcast(intent); } //------------------------ } else { // Remove package from internal structures, but keep around any // data that might have already existed deletePackageLIF(pkgName, UserHandle.ALL, false, null, PackageManager.DELETE_KEEP_DATA, res.removedInfo, true, null); } } catch (PackageManagerException e) { res.setError("Package couldn't be installed in " + pkg.codePath, e); } Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); }

2. Since the default desktop is set in Settings, the broadcast receiver adds and sets the default desktop in settings (add file-packages\apps\Settings\src\com\android\settings-UpdateLanucherReceiver.java)

package com.android.settings;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.ComponentName;import android.content.IntentFilter;import android.content.pm.PackageManager;import android.content.pm.ResolveInfo;import java.util.ArrayList;import android.util.Log;import android.content.pm.ActivityInfo;import java.util.List;public class UpdateLanucherReceiver extends BroadcastReceiver { public UpdateLanucherReceiver() { } @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.UPDATE_LANUCHER_APPS")) { Log.e("yhyh" ," onReceive"); final PackageManager mPm = context.getPackageManager(); //Package name class name of Dim Sum Desktop com.dianxinos.dxhome / com.nd.hilauncherdev.launcher. LauncherSet default Desktop ComponentName DefaultLauncher=new ComponentName(" com.dianxinos.dxhome", "com.nd.hilauncherdev.launcher.Launcher"); ArrayList homeActivities = new ArrayList(); ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities); ComponentName[]mHomeComponentSet = new ComponentName[homeActivities.size()]; for (int i = 0; i < homeActivities.size(); i++) { final ResolveInfo candidate = homeActivities.get(i); Log.e("yhyh","homeActivitie: candidate = "+candidate); final ActivityInfo activityInfo= candidate.activityInfo; ComponentName activityName = new ComponentName(activityInfo.packageName, activityInfo.name); mHomeComponentSet[i] = activityName; } IntentFilter mHomeFilter = new IntentFilter(Intent.ACTION_MAIN); mHomeFilter.addCategory(Intent.CATEGORY_HOME); mHomeFilter.addCategory(Intent.CATEGORY_DEFAULT); ListActivities=new ArrayList(); mPm.replacePreferredActivity(mHomeFilter, IntentFilter.MATCH_CATEGORY_EMPTY,mHomeComponentSet, DefaultLauncher); //refresh desktop Intent2 = new Intent(Intent.ACTION_MAIN); intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent2.addCategory(Intent.CATEGORY_HOME); context.startActivity(intent2); } }}

3.packages\apps\Settings\AndroidManifest.xml

Thank you for reading, the above is "Android 7.0 how to use MTK to set the default desktop" content, after the study of this article, I believe we have a deeper understanding of how to use MTK to set the default desktop in Android 7.0, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report