How to transmit data between different android applications ?, Android Transfer

Source: Internet
Author: User

How to transmit data between different android applications ?, Android Transfer

If you develop the android framework, the cooperation between different applications is often involved. You need to read or modify a shared data.

At this time, you can use the following two classes to solve the problem. These two classes are also frequently used in the framework.

SystemProperties, Settings. System


1. Use of SystemProperties.

In the framework, SystemProperties is often used to read or modify system properties. You can use this method to add properties to the system.

The read method is Systemproperties. get (name), and the method for modifying the attribute is Systemproperties. set (name, value ). Attribute names are subject to certain rules. The prefix of names must be written in the format defined in system \ core \ init \ property_service.c,

The following are the rules selected in the service:

 { "net.rmnet0.",    AID_RADIO }, { "net.gprs.",      AID_RADIO }, { "ril.",           AID_RADIO }, { "gsm.",           AID_RADIO }, { "net.dns",        AID_RADIO }, { "net.usb0",       AID_RADIO }, { "net.",           AID_SYSTEM }, { "dev.",           AID_SYSTEM }, { "runtime.",       AID_SYSTEM }, { "hw.",            AID_SYSTEM }, { "sys.",        AID_SYSTEM }, { "service.",    AID_SYSTEM }, { "wlan.",        AID_SYSTEM }, { "dhcp.",        AID_SYSTEM }, { "dhcp.",        AID_DHCP }, { "debug.",        AID_SHELL }, { "log.",        AID_SHELL }, { "service.adb.root",    AID_SHELL }, { "persist.sys.",    AID_SYSTEM }, { "persist.service.",   AID_SYSTEM }, { NULL, 0 }
The android system has permission requirements for calling this function:

A. Add android: sharedUserId = "android. uid. system" to the AndroidManifest file"

B. In Android. mk, set LOCAL_CERTIFICATE: = platform.


2. Use of Settings. system.

This is a frequently used class in Settings. It is used to read and modify Settings attributes. Modifications to the Settings attributes usually affect the global function of the mobile phone. To some extent, you can use System. system as the System attribute setting class.

The read method is Settings. System. getInt (contentResolver, name, value); set or modify the attribute method to Settings. System. putInt (contentResolver, name, value );

The data saved in this way is stored in the Settings database. Many Settings in Settings are saved in this way, such as the flight mode.

To use this method, you must register the permission in AndroidManifest.

<uses-permission android:name=”android.permission.WRITE_SETTINGS” />




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.