manifest中读取

meta-data在清单文件中主要有以下用法:

<application>
       <meta-data android:value="a1" android:name="a1"></meta-data>
</application>

//<application>用法
ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(),PackageManager.GET_META_DATA);
String msg=appInfo.metaData.getString("a1");

<activity>
       <meta-data android:name="a2" android:value="a2"></meta-data>
</activity>

ActivityInfo info=this.getPackageManager().getActivityInfo(getComponentName(),PackageManager.GET_META_DATA);
String msg=info.metaData.getString("a2");

<service>

<meta-data android:value="a3" android:name="a3"></meta-data>

</service>

ComponentName cn=new ComponentName(this, MetaDataService.class);
ServiceInfo info=this.getPackageManager().getServiceInfo(cn, PackageManager.GET_META_DATA);
String msg=info.metaData.getString("a3");

<receiver android:name="MetaDataReceiver">

<meta-data android:value="a4" android:name="a4"></meta-data>
</receiver>

ComponentName cn=new ComponentName(context, MetaDataReceiver.class);
ReceiverInfo info=context.getPackageManager().getReceiverInfo(cn, PackageManager.GET_META_DATA);
String msg=info.metaData.getString("a4");
上一篇:iOS应用数据存储2-SQLite3数据库


下一篇:Windows 7远程桌面设置