Run the command line to start the simulator and install and run launcher as a system-level program.

Source: Internet
Author: User

Only by installing and running launcher in the way of system and program can the default appwidget program be displayed when launcher is started. Otherwise

Java. Lang. securityexception: bindgagetid appwidgetid = 843 provider = componentinfo {com. Android. quicksearchbox/COM. Android. quicksearchbox. searchwidgetprovider }:
User 10047 does not have Android. Permission. bind_appwidget

This error occurs.

 

 

Emulator-AVD 1024_600_api8-partition-size 128
-- Here-partition-size 128 indicates that the system partition is expanded to 128 MB. If necessary, you can set it to a larger system partition.

ADB remount
-- Make the/system partition writable. Otherwise, the following push command will appear, as shown in "failed to copy 'launcher2_custom.apk 'to system/APP/launcher2_meiling.apk ': read-Only file system error prompt

ADB push launcher2_custom.apk/system/APP

When you no longer need this custom launcher APK, you can directly Delete the corresponding APK file in/system/APP in ADB shell mode.

With the same principle, an appwidget (such as the real-time temperature control center of ML) is automatically displayed on the desktop at startup. The annotations and steps are as follows:

1. launcher2 source codeRes/XML/default_workspace.xmlDefines the layout of each sub-desktop in the launcher. Each sub-desktop corresponds to a celllayout (viewgroup subclass), and each celllayout contains multiple cells, each component on the desktop occupies an integer cell in the x/y direction.

 

2. In launcher. Java of launcher2 source code, the definition is as follows:
Static final int screen_count = 4; -- launcher contains several screens
Static final int default_screen = 0; -- Which screen is displayed by default after launcher is started
Static final int number_cells_x = 9; -- the number of cells horizontally included in the celllayout corresponding to each screen
Static final int number_cells_y = 5; -- how many cells are contained vertically in the celllayout corresponding to each screen?

 

3. The example of appwidget added in default_workspace.xml is as follows:

<Appwidget
Launcher: packagename = "com. ml. Apps"
Launcher: classname = "com. ml. Apps. timetemperinforeceiver"
Launcher: screen = "0" -- in which screen the widget is displayed
Launcher: x = "0" -- the initial cell-X of this appwidget in screen
Launcher: Y = "0" -- the initial cell-y of this appwidget in screen
Launcher: Spanx = "9" -- cell span-X of this appwidget in screen
Launcher: spany = "5" -- cell span of this appwidget in screen-y
/>

 

4. The layout of the appwidget added in default_workspace.xml must adapt to the appwidget settings in the corresponding application; otherwise, the layout cannot be correctly displayed. The res/XML/APP corresponding to the appwidget contains a widget layout description file, for example, home_widget_provider.xml. The corresponding content is as follows:

<? XML version = "1.0" encoding = "UTF-8"?>
<Appwidget-provider xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: minheight = "368dp" Android: minwidth = "664dp"
Android: initiallayout = "@ layout/cell_main" Android: updateperiodmillis = "0">

</Appwidget-provider>

 

Note:When setting Android: minheight and Android: minwidth, the actual number of cells occupied by widgets is set. According to the practice, it seems that no matter in dimens. the actual values of workspace_cell_width and workspace_cell_height defined in the XML file are as follows: Android: minheight and Android: minwidth are set in the X and Y directions according to each cell 74dp., That is, 74 × cell _ Numbers-2. For example, the Launcher: Spanx = "9", Launcher: spany = "5" defined in (3) above, where
Android: minheight = "0000dp" (5 × 74-2), Android: minwidth = "664dp" (9*74-2)

5. After the above four steps, the basic work is completed, and then the application and launcher program corresponding to the appwidget are pushed to the/system partition, namely:
ADB push timertemperinfo.apk/system/APP
ADB push launcher2_meiling.apk/system/APP

You can. Practice shows that the push sequence of these two APK programs does not seem to have any impact.

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.