android appwigt

 

 

package com.example.test1;

import android.os.Bundle;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_main);
	ActivityInfo  activityInfo;
	try {
        activityInfo=getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
      String _getMetaData  =activityInfo.metaData.getString("app.activity.meteactivity");
        Toast.makeText(this,_getMetaData , 3000).show();
	
	} catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
	
	
	}



}

 mainifest.xml 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test1"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.test1.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="app.activity.meteactivity" android:value="Hello Good!"></meta-data>
        </activity>
    </application>

</manifest>

 

posted @ 2016-08-30 12:38  每天进步一点点!  阅读(503)  评论(0编辑  收藏  举报