Androidmanifest. XML (4) uses-permission-translated from beginning Android games

Source: Internet
Author: User
Tags android games

The <uses-Permission> element

 

Now let's say goodbye to the <Application> element and return to the child element defined in <manifest>. <uses-Permission> is one of the elements we will discuss next.

Android has a well-designed security model. Each application has its own Linux users and groups and runs on a separate process and Vm, which cannot affect other applications. Android also limits the use of system resources, such as network devices, SD cards, and recording devices. If your application wants to use any system resources, we must apply for Android permissions. This is the role of the <uses-Permission> element.

 

A permission is usually in the following format, and a string named name is used to guide the permissions we want to use.

 

<Uses-Permission Android: Name = "string"/>

 

There are some possible permission names:

Android. Permission. record_audio: it allows us to use the recording device.

Android. Permission. Internet: it allows us to use all networking APIs. For example, we can get an image from the Internet or update the highest value on the Internet.

Score.

Android. Permission. write_external_storage: it allows us to read and write external storage devices, usually the device's SD card.

Android. Permission. wake_lock: it allows us to lock a so-called wake lock. Using wake lock, we can avoid setting

Standby sleep (when the screen is not touch screen for a long time ). For example, how can this happen when only acceleration sensors are used.

To obtain the permission to use networking APIs, we specify the following elements as sub-elements of <manifest>.

<Uses-Permission Android: Name = "android. Permission. Internet"/>

 

To add other elements, simply add more <uses-Permission>. You have many other permissions to specify.

We recommend that you query the official Android documentation. We only need to use the elements we just discussed.

If you forget to add some permissions for using the SD card, a public error will occur. manifests has messages in logcat, but it may not be messy.

Detected in logcat. Think about what permissions are required by the game and specify them before starting game development.

 

On the other hand, it should be noted that when you install your application, the user will first visit the permissions required by the application. Some users may skip these steps and then open

Install the application with your heart, no matter whether or not they will. In addition, some users may consciously have the permission to visit. If your application has some sensitive permissions, such

If you send a large number of text messages or get users' location, you may receive negative comments on Google market. If you use a problematic sensitive permission,

Tell the user why you want to use it. The best way is to avoid using these sensitive permissions.

 

Next is <uses-feature>

Attached Original:

 

The <uses-Permission> element
We are leaving the <Application> element now and coming back to elements we define
As children of the <manifest> element. One of these elements is the <uses-Permission>
Element.

Android has an elaborate security model. Each application is run in its own process and
VM, with its own Linux user and group, and cannot influence other applications. Android
Also restricts the use of system resources, such as networking facilities, the SD card,
And the audio-recording hardware. If our application wants to use any of these system
Resources, we have to ask for permission. This is done with the <uses-Permission>
Element.

 
A permission always has the following form, where string specifies the name of
Permission we want to be granted:

<Uses-Permission Android: Name = "string"/>
Here are a few permission names that might come in handy:
Android. Permission. record_audio: This grants us access to
Audio-recording hardware.

Android. Permission. Internet: This grants us access to all
Networking APIs so we can, for example, fetch an image from the net
Or upload high-scores.

Android. Permission. write_external_storage: This allows us to read
And write files on the external storage, usually the SD card of
Device.

Android. Permission. wake_lock: This allows us to acquire a so-called
Wake lock. With this wake lock we can keep the device from going
Sleep If the screen hasn't been touched for some time. This cocould
Happen in a game that is controlled only by the accelerometer,
Example.

To get access to the networking APIs, we 'd thus specify the following element as a child

Of the <manifest> element:

<Uses-Permission Android: Name = "android. Permission. Internet"/>
For any additional permissions, we simply add more <uses-Permission> elements. There

Are more permissions you can specify; I again refer you to the official android

Documentation. We'll only need the set just discussed.

Forgetting to add a permission for something like accessing the SD card is a common

Error source that manifests itself as a message in logcat, which might keep ve
Undetected due to all the clutter in logcat. Think about the permissions your game will

Need and specify them when you create the project initially.

Another thing to notice is that when a user installyour application, she will first be

Asked to review all the permissions your application wants. Users users will just skip

Reading those and happily install whatever they can get ahold of. Some users are more

Conscious about their decisions and will review the permissions in detail. If you request

Suspicious permissions, like the ability to send out costly SMS messages or get a user's

Location, you may receive some nasty feedback from users in the comments section

Your application in the market. If you use one of those problematic permissions, then tell

The user why you're using it in your application description. The best thing is to avoid

Those permissions in the first place, though.

Related Article

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.