开发者

AndroidManifest.xml

开发者 https://www.devze.com 2023-01-08 17:29 出处:网络
I came across the following two lines in AndroidMenifest.xml file of my android application: <?xml version=\"1.0\" encoding=\"utf-8\"?>

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开发者_JAVA百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消