android appwigt
Posted 每天进步一点点!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>
以上是关于android appwigt的主要内容,如果未能解决你的问题,请参考以下文章