[android]代码库
package com.njupt.metadata;
import android.os.Bundle;
import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void get(View v){
try {
PackageManager pm = getPackageManager();
ComponentName component = new ComponentName(this,MainActivity.class);
ActivityInfo info = pm.getActivityInfo(component,PackageManager.GET_META_DATA);
Bundle bundle = info.metaData;
String java_ns = bundle.getString("java_ns");
int balance = bundle.getInt("balance");
String c_ns = bundle.getString("c++_ns");
String wife = getString(bundle.getInt("wife"));
System.out.println("java_ns: " + java_ns + ", balance: " + balance +",c_ns: " + c_ns +",wife: " + wife);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
by: 发表于:2018-01-10 11:16:12 顶(0) | 踩(0) 回复
??
回复评论