Android built-in desktop icon link URL

Source: Internet
Author: User
From: http://blog.csdn.net/xubin341719/article/details/7621126

Problem:

Today, I have a customer who asked me to create an icon on the desktop and click link to their company's website. I have used application shortcuts before and put them on the desktop by default, such as creating Desktop shortcuts and plug-ins for Android, you have not done any previous URLs.

Considerations:

(1) make a small application, call the system browser, and write a fixed website address;

(2) Add the URL to the desktop default value.

Obviously, the second solution is simpler. You can find this method on the Internet as follows:

I. Read the desktop icon

/Packages/apps/launcher/RES/XML/Default_workspace.xmlThe desktop marker arrangement is recorded when the system initializes or restores the factory settings. After the launcher program runs for the first time, it creates a record in/data/COM. Android. launcher/databases/launcher. DB, which contains all the current desktop icons. In the future, the desktop icon will only be read from here at each startup.

Ii. default_workspace.xml Analysis
Default_workspace.xmlSupported labels:
Favorite: Application shortcut.
Shortcut cut: links, such as URLs and local disk paths.
Search: search box.
Clock: clock widget on the desktop
Supported attributes include::
Launcher: Title: The text under the icon. Currently, only references are supported and strings cannot be written directly;
Launcher: icon reference;
Launcher: URI:Link address. This is the main character.
Launcher: packagename: package name of the application;
Launcher: classname: the startup Class Name of the application;
Launcher: screen: the number of the screen where the icon is located;
Launcher: X: Number of icons arranged horizontally;
Launcher: Y: the serial number of the icon in the vertical arrangement;

The loadfavorites method in launcherprovider. Java is responsible for parsing.

Iii. Solutions for Network Connections

There are many default_workspace.xml writing methods for applications, but there is no link writing method. I analyzed its parsing program and reversed the link shortcut writing method, which has been verified successfully, hope to help you.
[HTML]View
Plaincopy

  1. <Shortcut
  2. Launcher: Title = "@ string/Baidu"
  3. Launcher: icon = "@ drawable/Baidu"
  4. Launcher: uri = "http://www.baidu.com"
  5. Launcher: screen = "1"
  6. Launcher: x = "0"
  7. Launcher: Y = "3"/>


The icon content and text content of the link are obtained from default_workspace.xml.
The application's icon content and text content under the icon are obtained from packagemanager.
If the package name and Class Name of the application are not found in packagemanager for some reason at launcher startup, the desktop will not display its icon. If the class name and package name are found but the icon is not found, the default robot icon for Android is displayed.
Therefore, when adding a spindle to default_workspace.xml, you only need to write the title, icon, Uri, screen, X, and y attributes.
To add an application, you only need to write the attributes packagename, classname, screen, X, and Y.

Related Article

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.