2016-03-30 16 views
0
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.emnets.luoly.sample" 
    android:versionCode="1" 
    android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="24" 
    android:targetSdkVersion="19" /> 

<uses-permission android:name= "android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name= "android.permission.INTERNET" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" > 
    <activity android:name="com.emnets.luoly.sample.MainActivity" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    </application> 
</manifest> 

uses-permission groovy'yi kullanmak istiyorum. Belki böyle groovy, getiri niteliktedir AndroidManifest.xml

, android.permission.WRITE_EXTERNAL_STORAGE

cevap

3

Sen XmlSlurper

def manifestXml = new XmlSlurper().parse(Manifest) 
manifestXml."uses-permission".each { p -> 
    println p."@android:name" 
} 
0

Kullanım XmlSlurper

def manifest = new XmlSlurper().parse(xmlFilePath) 
    String pkg = [email protected] 
    manifest.application.activity.each { 
     String actName = it.'@android:name' 
     if (actName.substring(0, 1).equals('.')) { 
      actName = pkg + actName 
     } 
     println(actName) 
    } 
ActivityName almak kullanabilirsiniz gibi

def manifestXml = new XmlParser().parse(Manifest) 
manifestXml."uses-permission".each { p -> 
      println p.attribute("android:name") 
     } 

nasıl alınır bağlıyor