Your Android app doesn't need that much permission at all

Source: Internet
Author: User

The permissions of the Android system from the user's point of view sometimes is a bit confusing. Sometimes you just need to do something simple (edit the contact's information), but apply for more permissions than you need for your app (such as access to all your contact information).

It's hard not to let users keep an alert on you. If your app is still closed, there's no way to verify that your app is uploading his contact information to the application server . Even if you explain to the user why you are applying for this permission, they may end up believing you. So I used to avoid using some artifice when I was developing Android apps, because it would apply for additional permissions and users would not trust you.

After a period of practice, I have the experience that you do not need to apply for permission when you complete certain operations.

For example, the Android system has such a permission: android.permission.CALL_PHONE . You need this permission to let you invoke the dialer from your app, right? The code below is if you make a call, right?

<span style= "FONT-SIZE:14PX;" >intent Intent = new Intent (Intent.action_call), Intent.setdata (Uri.parse ("1234567890")) startactivity (Intent); </span>

Wrong! This permission allows your phone to call without user action! In other words, if my app uses this permission, I can call the harassment phone three o'clock in the morning every day without your knowledge.

In fact, the right thing to do is this-use ACTION_VIEW or ACTION_DIAL :

<span style= "FONT-SIZE:14PX;" >intent Intent = new Intent (intent.action_dial), Intent.setdata (Uri.parse ("1234567890")) startactivity (Intent); </span>

The beauty of this scheme is that your app doesn't have to apply for permission. Why don't we need permission? Because the Intent you are using will start the dialer and dial the number you set up beforehand. Compared to the previous scheme, the user now needs to click "Dial" to call, without the user's participation, this call will not be out. To tell the truth, it makes me feel good, and now many application permissions are a bit overwhelming.

Another example: I wrote a Quick Map app for my wife, which was designed to solve her own groove for existing navigation applications. She just wants a list of contacts and a path to navigate to the location of those contacts.

See here you may think I need to apply for access to all contact information to complete this application: hahaha, you're wrong again! If you look at my source code , you know I actually used ACTION_PICK this intent to launch the app to get the contact address:

<span style= "FONT-SIZE:14PX;" >intent Intent = new Intent (Intent.action_pick); Intent.settype (Structuredpostal.content_type); Startactivityforresult (Intent, 1);</span>

This means that my app doesn't have to apply for permissions, and doesn't have an extra UI. This has increased the user experience for the app.

In my opinion, one of the coolest parts of the Android system is its Intent system. Because intent means that I do not need anything to be realized by myself. Each app registers with Android the data areas it specializes in, such as phone numbers, text messages, or contact information. If everything needs to be addressed in one application, the application becomes bloated.

Another advantage of the Android system is that I can take advantage of the permissions applied by other apps so that my app doesn't need to be re-applied. The above two points in the Android system can make your application easier. The dialer needs permission to make a call, but I just need a intent to make a call, no permissions required. This is good because the user trusts the dialer that comes with Android, but doesn't trust my app.

The point of my writing this blog is that before you apply for permission, you should at least read the official documentation about intent to see if you can do it through other apps. If you want to know more about it, you can look into this official document about permissions , which describes more granular permissions. If you want to get a better user experience, it is also very necessary, that is the security of the application, on this point can see the Professional Application Security Service provider Love encryption Application security solution

In short, using fewer permissions will not only allow you to gain more user trust, but also give users a good user experience.

Your Android app doesn't need that much permission at all

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.