Android MIUI notification SMS permission

MIUI has a lot of pit father designs. For example, MIUI's mobile phone can't debug and install applications via USB without a SIM card. Well, plug it in, and you'll log in to Xiaomi's account first (there's nothing to say). MIUI permission application is also a pit!

Take read_ For the permission of SMS, it is dynamically applied according to the Android specification. It does not pop up a window for the user to allow, and then the callback is successful. Go to the settings and see that the permission is still asking for the status. What logic is this! Then I want to automatically fill in the SMS verification code. I'm not conscious. I MIUI customized a service_sms. You don't know how to apply or register in the manifest. So you have no right and can't monitor. I don't know the name of the complete permission. There are only two states in the settings (there is no inquiry, and it is estimated that there is no dynamic application).

At present, there is a scheme that you guide users to open, but now SMS is in the form of notification bar and there will be a copy button. This is actually unnecessary, but it may be valuable if it is other sensitive permissions. As follows:

1. First judge whether the system is MIUI, and then call gopermissionsettings (activity activity) in the required activity;

2. Rewrite onactivityresult in the corresponding activity according to request_ Code, the callback directly executes the business code that needs permission. However, it is impossible to judge whether the user has given permission or not. He can only "blind tune" (a word created by himself) the code that needs permission, so he needs to try / catch. If it breaks, it means that he has no permission, and if there is no problem, it means that he has given permission.

3. You can record the authorization status with sharepreference instead of booting it every time (but it may still be turned off manually after the user gives permission). The above try / catch is very important. You can do some processing in catch and guide again, or you have other ideas.

Give a useful ADB command. You can get the information of the current activity. Otherwise, how do you know the package name and full class name of the activity set by MIUI permission in the gopermissionsettings (activity) method above

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>