How do I pass data between different Android apps?

Source: Internet
Author: User

If you do the development of the framework of Android, it will often involve the cooperation between different applications and need to read or modify a shared data.

At this point you can use the following two classes to solve the problem, the use of the two classes in the framework also has a regular appearance.

Systemproperties,settings.system


the use of 1.SystemProperties.

In the framework, systemproperties, which is commonly used to read or modify system properties, can be used to add properties to the system.

Where the Read method is systemproperties.get (name), the method to modify the property is systemproperties.set (name, value). The name of the property has a certain rule, and the prefix of the name is written in theformat defined in S ystem\core\init\property_service.c .

The following are the rules that are selected in the service:

{"Net.rmnet0.",    Aid_radio}, {"Net.gprs.",      Aid_radio}, {"Ril.",           Aid_radio}, {"GSM.",           Aid_radio}, {"Net.dns",        Aid_ra  DIO}, {"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", C17/>aid_shell}, {"Persist.sys.",    Aid_system}, {"Persist.service.",   Aid_system}, {NULL, 0}
The Android system has permission requirements for methods that call this function:

A. Add android:shareduserid= "Android.uid.system" to the Androidmanifest file

B. In android.mk, set the Local_certificate:=platform.


the use of 2.settings.system.

This is a class commonly used in settings to read and modify settings properties, and changes to settings properties often affect the global functionality of the phone. So in a way, you can use System.system to set the class as a system property.

The Read method is Settings.System.getInt (contentresolver, name, value); Set or modify the property method to Settings.System.putInt (Contentresolver, name, Value);

The data stored in this way is stored in the settings database, and many of the settings in settings are saved in this way, such as airplane mode.

Use this method to register permissions in Androidmanifest

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




How do I pass data between different Android apps?

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.