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 Launcher to export database to another machine to load in Android data transfer

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

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Launcher to export the database to another machine to load in Android data transfer." interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use Launcher to export a database to another machine to load in Android data transfer."

Function description

1. Export the current launcher layout.

Copy the layout file to another machine. (simulate upload and download server layout file)

3. Update launcher layout.

Demand analysis

1. Copy the database

2. Import the database

3. Classify desktop icons:

App folder does not need to be modified and can be displayed directly.

Widget, deepshortcut and 1*1shortcut need to be adapted before they can be displayed.

Implementation idea 1. Export launcher layout

You just need to copy the launcher database

2. Import the database

Copy the database file to the launcher data/data/ package name / database/launcher.db

It should be noted that because when launcher is running, replacing the database file will cause the old database object DatabaseHelper to be unable to operate the new database. If you do not deal with it, crash; will need to reinitialize the database object or restart launcher to complete the copy action before database initialization.

3. Adapt to the types of icons supported by the desktop

In loadWorkspace, load the information from the database:

3.1The app folder does not need to adapt.

3.2 、 widget:

Widget adaptation. Refer to the default configuration layout to read the database from xml and load the widget process.

If the default layout of widget can be configured, you can read the package class name from the database and match it, as long as you ensure that they follow the same process.

Case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET://widget needs to update widgetID and widget statusif (copySuccess) {c.restoreFlag = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID | LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY | LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG;}

3.3 、 deep shortcut:

Case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT://deep shortcut will register the information in the system / / We need to register to the system manually according to the contents in the database, so that the user can display / / 1 normally after restarting the machine, and query the registered deepshortcutList pinnedShortcuts = mShortcutManager.queryForPinnedShortcuts (null, user). / / obtain pinnedShortcut according to database key, which cannot be obtained here, because the new phone is not registered} else if (c.itemType = = LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {ShortcutKey key = ShortcutKey.fromIntent (intent, c.user); if (unlockedUsers.get (c.serialNumber)) {ShortcutInfo pinnedShortcut = shortcutKeyToPinnedShortcuts.get (key) / there are two kinds of shortcuts, the CREATE_SHORTCUT written in manifest, the kind of / / LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC//LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST//LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED// fixed interface deepShortCut that pops up when pressing the icon for a long time, such as setting BatterySaver Key is 1 / 1 unadapted if in com.android.settings/manifest-shortcut-batterySaver#UserHandle {0} / / and / / widget lists (pinnedShortcut = = null & & copySuccess) {DeepShortcutManager sm = DeepShortcutManager.getInstance (context) List si = sm.queryForFullDetails (intent.getPackage (), null, c.user); shortcutKeyToPinnedShortcuts_copyDbFile.clear (); Log.i (TAG, "key:" + key); for (ShortcutInfo shortcut: si) {ShortcutKey shortcutKey = ShortcutKey.fromInfo (shortcut); shortcutKeyToPinnedShortcuts_copyDbFile.put (shortcutKey, shortcut); Log.d (TAG, "shortcutKey:" + shortcutKey) } pinnedShortcut = shortcutKeyToPinnedShortcuts_copyDbFile.get (key); if (pinnedShortcut! = null) {copyDbFileNeedAddTo = true;}} / / bind shortcutcom/tblenovo/launcher/model/BgDataModel.java// Since this is a new item to the underlying layer, pin the shortcut in the system server.//ccsDeepShortCut need pinShortcutif ((newItem | | ccsDeepShortCUTItem) & & count.value = = 1) {DeepShortcutManager.getInstance (context) .pinShortcut (pinnedShortcut);}

3.4 、 11widget:

/ / 11 in the widget list does not fit

Long press the process of adding 1 plug-in in setting:

1. Create a shortcut attribute shortcutInfo

2. Apply to the underlying layer to create the Intent of the shortcut createShortcutResultIntent

3. Fixed shortcut createWorkspaceItemFromPinItemRequest

12 normal steps should be carried out in setting, 3 in launcher.

All executed in launcher, unable to achieve the desired results.

When starting a shortcut, you need to start it according to the package name and id

If it is the package name of launcher, you can only open the settings home page and cannot skip to the corresponding shortcut interface.

It is not possible for 1*1widget to bind to the underlying layer only with pinShortcut, and it cannot be successfully bound.

/ / failed to register shortcut// registration with the system, will detect the package name and the package name in data WorkspaceItemInfo infoinfo = LauncherAppsCompatVO.createWorkspaceItemFromPinItemRequest (context, LauncherAppsCompatVO.getPinItemRequest (data), 0); / / and then go to the above pinShortcut to complete this. I believe you have a deeper understanding of "how to use Launcher to export the database to another machine in Android data transfer". You might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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