No permission to write APN settings:neither user * * and current process have android.permission.WRITE_APN_SETTINGS.

Source: Internet
Author: User

In previous versions of ICS40, if the program needed to set up an APN, simply declare the permission in the Androidmanifest file. Running on a 40 machine throws the following exception: Java.lang.SecurityException:No permission to write APN settings:neither user * * Nor current process H As Android.permission.WRITE_APN_SETTINGS.

The reason is that Google has blocked third-party apps ' access to APN based on security concerns, and some people on the web say the program is set up as a system app. It is possible to put the APK into the/system/app/directory via the ADB push command, but most apps are used as third-party applications, which is unlikely to be feasible. This allows the app to have APN access using the system signature.

The first method is simple, but it needs to be compiled with make in the context of the Android system source code:

       1. Add the manifest node in the androidmanifest.xml of the applicationandroid:shareduserid= "Android.uid.system"this property.

       2. Modify the Android.mk file to addlocal_certificate: = PlatformThis line

       3. Using the MM command to compile, the generated apk will have the ability to modify the system time.

The second method is troublesome, but do not need to open the virtual machine to the source environment with make to compile:

       1. Ibid., Joinandroid:shareduserid= "Android.uid.system"this property.

       2. Use Eclipse to compile the apk file, but this apk file is not available.

       3. Open the APK file with the compression software, delete the cert.sf and cert.rsa two files in the Meta-inf directory.

       4. Useplatform key for target systemto re-sign the apk file. This step is more troublesome, first find the key file, the location in my Android source directory is "Build\target\product\security", the followingPlatform.pk8 and Platform.x509.pemtwo files. Then use the SIGNAPK tool provided by Android to sign, signapk the source code is under "build\tools\signapk", use forJava-jar signapk.jar platform.x509.pem platform.pk8 ***.apk ***_signed.apk get apk with corresponding permissions.

tools and Keys: http://download.csdn.net/detail/bulkin/4329253

       this way the last apk is the same as the first one.

       finally explain the principle, first add android:shareduserid= "Android.uid.system" this attribute. With the shared user ID, multiple apk with the same user ID can be configured to run in the same process. Then the UID of the program into a android.uid.system, that is, to let the program run in the system process, so that there is permission to modify the system time.

       just adding UID is not enough, if you install the APK at this time found unable to install, indicating that the signature does not match, because the program wants to run in the system process and the target system platform. Key, The second method mentioned above is the PLATFORM.PK8 and Platform.x509.pem two files. Using these two keys to sign the APK before it can actually be put into the system process. The first method adds Local_certificate: = Platform is actually signed with these two keys.

       There is also a problem, that is, the generated programs can only be used in the original Android system or in their own compiled system, because such a system can get platform.pk8 and Platform.x509.pem two files. If the other company does not have the Android installed on the installation. Try the original Android key to sign, the program runs OK on the emulator, but put on the G3 to install the direct prompt "package ... has no signatures that match those in shared user Android.uid. System ", which also protects the security of the systems.

       last but not least, this Android:shareduserid property can not only put the APK into the system process, you can also configure multiple apk running in a process, so that the data can be shared, it should be useful


Source: http://blog.sina.com.cn/s/blog_5da93c8f0101cbp7.html

1, you are not used to obtain the APN information (if used and non-mandatory can be deleted)

2, if you have to use the APN information, you should pay attention to version compatibility issues, the android4.2 above version of the APN URI has changed.

Did you call the query APN operation in your code with the following version: Uri Preferred_apn_uri = URI. Parse ("CONTENT://TELEPHONY/CARRIERS/PREFERAPN"); Contentresolver contentresolver = Context.getcontentresolver (); cursor cursor = contentresolver.query (Preferred_apn_uri, NULL, NULL, NULL, or NULL); More than 4.2 versions remove this paragraph or replace it with a version of 4.2 or more. To judge the version <a Target=_blank target= "_blank" href= "" rel= "nofollow" style= "Color:rgb (45 , 100, 179); Text-decoration:none; " ></a> I'm just going to get rid of it, because it's not very important to me. Only a hint to the user what the network is!

Source: http://www.68idc.cn/help/buildlang/ask/20150517342775.html

From for notes (Wiz)

No permission to write APN settings:neither user * * and current process have android.permission.WRITE_APN_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.