Your Android application does not require that many permissions.

Source: Internet
Author: User

Your Android application does not require that many permissions.

The permissions of the Android system are a bit confusing from the user's perspective. Sometimes you only need to edit the contact information in some simple ways, but you have applied for more permissions than your application needs, such as permission to access all contact information ).

It is hard to prevent users from saving your guard. If your application is still closed-source, you cannot verify whether your application is uploading its contact information to the application server. Even if you explain to the user why you applied for this permission, they may not trust you at last. Therefore, when I used to develop Android apps, I avoided using some tricks, because this will apply for additional permissions and users will not trust you.

After a period of practice, I have the following experience:You do not have to apply for permissions when completing some operations.

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

 
 
  1. Intent intent = new Intent(Intent.ACTION_CALL); 
  2. intent.setData(Uri.parse("1234567890")) 
  3. startActivity(intent); 

Error! This permission allows you to make a phone call without any user operation! That is to say, if my application uses this permission, I can call the harassing phone at three o'clock every morning without your knowledge.

In fact, the correct way is to use ACTION_VIEW or ACTION_DIAL:

 
 
  1. Intent intent = new Intent(Intent.ACTION_DIAL); 
  2. intent.setData(Uri.parse("1234567890")) 
  3. startActivity(intent); 

The beauty of this solution is that your application does not need to apply for permissions.Why don't I need permissions? Because the Intent you are using will start the dial and pre-dial the number you have set. Compared with the previous scheme, users still need to click "dial-up" to make a call. without the user's participation, the call will not be available. To be honest, this makes me feel very good. Now, the permissions applied by many applications are a bit confusing.

Another example: I wrote a Quick Map application for my wife. This application is mainly used to solve her problem with the existing navigation application. She only wants a contact list and a path to the location of these contacts.

Here, you may think that I need to apply for access to all the contact information to complete this application: Hahaha, you are wrong again! If you read my source code, you will know that I used the Intent ACTION_PICK to start the application to get the contact address:

 
 
  1. Intent intent = new Intent(Intent.ACTION_PICK); 
  2. intent.setType(StructuredPostal.CONTENT_TYPE); 
  3. startActivityForResult(intent, 1); 

This means that my application does not need to apply for permissions, but does not need additional UIS. This improves the user experience of applications.

In my opinion, one of the coolest parts of the Android system is its Intent system. Because Intent means that I don't need to implement anything on my own. Every app registers the data fields it specializes in on Android, such as phone numbers, text messages, or contact information. If an application is needed to solve everything, the application will become very bloated.

Another advantage of the Android system is that I can use the permissions applied by other applications, so that my applications do not need to apply again. The above two points in the Android system can make your application simpler. The Dialer requires the permission to call the phone, but I only need a intent to call the phone. This is because the user trusts the dial that comes with Android, but does not trust my application.

The significance of writing this blog isBefore applying for permissions, you should at least read them carefully.Official Intent documentationTo see if other applications can be used to complete your operations.If you want to learn more, you can take a look at this official document on permissions, which introduces more detailed permissions.

In short, using less permissions not only gives you more user trust, but also gives users a good user experience.

Source: Dan Lew I don't need your permission!

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.