简体   繁体   中英

AndroidManifest.xml

I came across the following two lines in AndroidMenifest.xml file of my android application:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  1. Why we have write "encoding" in <xml> tag, what is the purpose of it?
  2. What is the purpose of writing 2nd line ?

if anybody know this, may share their knowledge to let me clear regarding this 2 lines

Thanx - paresh

Since you found out the first line by yourself, I'll explain you only the second. It just sets up the android XML namespace. When using own resources, you should add their namespaces too, like:

xmlns:myapp="http://schemas.android.com/apk/res/com.mypackage

This will declare the myapp namespace.

First line is not required for writing your xml, but it is good practice to have it as the first line of your XML and if you are using any other encoding then it becomes necessary.
Second line is required because manifest should be the root node of Android Manifest xml. And as a matter of fact it gets closed at the end of file by </manifest> just like any other node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM