The previous time guide completed the game development project. Which is used for packing in bulk.
The network currently on the market is not submitted. However, the game ID number is changed by setting the meta_data> in manifest to get the relevant number of references. The game ID changes and then the game content changes. It was in the activity that I wrote the number of references.
I checked some papers today and concluded.
Are included in the <activity>, <application>, <service>, and <receiver> elements, different parent elements, and the methods that are read at the time of application are also different. They all have the relevant info read. 1: In the Activity app <meta-data> elements. XML snippet: <activity...> <meta-data android:name= "Data_name "Android:value=" Hello my activity ></meta-data> </activity> Java Code Snippets: activityinfo Info=this.getpackagemanager () & nbsp Getactivityinfo (Getcomponentname (), &N Bsp packagemanager.get_meta_data); String msg =info.metadata.getstring ("Data_name "); LOG.D (TAG," msg = = "+ msg); 2: Apply <meta-data> element in application. xml Code snippet: <application...> <meta-data android:value= "Hello my Application "Android:name=" Data_name "></meta-data> </application> java Code snippet: ApplicationInfo appInfo = This.getpackagemanager () Getapplicationinfo (Getpackagename (), & nbsp packagemanager.get_meta_data); String msg=appinfo.metadata.getstring ("Data_name"); LOG.D (TAG, "msg = =" + msg); 3: In the Service Application <meta-data> element. xml Code snippet: <service android:name= "MetadataService" > <meta-data android:value= "Hello my Service" android:name= "Data_name" ></meta-data> </service> java Code snippet: componentname cn=new componentname (this, metadataservice.class); ServiceInfo Info=this.getpackagemanager () GetServiceInfo (cn, packagemanager.get_meta_data); String msg= Info.metaData.getString ("Data_name"); LOG.D (TAG, "msg = =" + msg); 4: Application <meta-data> element in receiver.
xml Code snippet: <receiver android:name= "Metadatareceiver" > <meta-data android:value= "Hello my Receiver" android:name= "Data_name" ></meta-data> <intent-filter> <action Android:name= "Android.intent.action.PHONE_STATE" ></action> </ intent-filter> </receiver> java code snippet: componentname cn=new componentname (context, Metadatareceiver.class); Activityinfo Info=context.getpackagemanager () .getreceiverinfo (CN, Packagemanager.get _meta_data); String msg=info.metadata.getstring ("Data_name"); LOG.D (TAG, "msg = =" + msg);
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Android Gets the value of manifest in <meta-data> components