"Learning Notes" Android permissions action

Source: Internet
Author: User

One, add network permissions to Android

Add a line of code in the Androidmanifest.xml file to allow Internet permissions

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/5B/wKiom1gQcB3zvgxIAAAZlBInjMs436.png "title=" Qq20161026165756.png "alt=" Wkiom1gqcb3zvgxiaaazlbinjms436.png "/>

Second, add check permission to a method

First, define a permission constant, add the context parameter to the method, check whether the permission is allowed by the context's Checkcallingorselfpermission method, and if allowed, throw an exception if not allowed

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/5C/wKiom1gQdy_DjkoZAABF48oUAH0621.png "title=" Qq20161026172805.png "alt=" Wkiom1gqdy_djkozaabf48ouah0621.png "/>

In the Manifestactivity.xml file, you need to add a line permission code to register this permission, and then add a line Uses-permission code that allows authorization

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/59/wKioL1gQd3_x6-tEAAAqWC9gZLo772.png "title=" Qq20161026172927.png "alt=" Wkiol1gqd3_x6-teaaaqwc9gzlo772.png "/>

Third, add permissions to an activity

1) If the activated activity and the activated activity are in an application, you will need to add permission to the activated activity information in the Manifestactivity.xml file.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/59/wKioL1gQfgfyXFVzAAAReQW_cFM649.png "title=" Qq20161026175711.png "alt=" Wkiol1gqfgfyxfvzaaareqw_cfm649.png "/>

And then declare the permission at the top

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/5C/wKiom1gQfjDCWVwBAAAVb4UwVKY603.png "title=" Qq20161026175758.png "alt=" Wkiom1gqfjdcwvwbaaavb4uwvky603.png "/>

2) If the activity being activated is not in an application, add the permission information to the activated activity in Manifestactivity.xml and add the Intent-filter information action

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/5C/wKiom1gQfvSQnYuoAAAvr76RM5o336.png "title=" Qq20161026180112.png "alt=" Wkiom1gqfvsqnyuoaaavr76rm5o336.png "/>

The same permission is declared above

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/89/5C/wKiom1gQf26AxHf_AAAVb4UwVKY153.png "title=" Qq20161026175758.png "alt=" Wkiom1gqf26axhf_aaavb4uwvky153.png "/>

Add use-permission code to the manifestactivity.xml of the application that started the activity

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/89/5A/wKioL1gQf76BJVQlAAARtC5JsIk059.png "title=" Qq20161026180439.png "alt=" Wkiol1gqf76bjvqlaaartc5jsik059.png "/>


"Learning Notes" Android permissions action

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.