标签:android style blog color io os ar div sp
public class MainActivity extends ActionBarActivity { private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //获取当前项目版本号 mTextView = (TextView) findViewById(R.id.textView1); try { getVersionName(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //Android系统版本信息 String Model_VERSION="Android系统版本信息: " + android.os.Build.MODEL + ",API " + android.os.Build.VERSION.SDK + ",Android " + android.os.Build.VERSION.RELEASE; //显示信息 try { mTextView.setText("当前程序版本: "+ getVersionName()+"\n"+Model_VERSION ); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private String getVersionName() throws Exception { // 获取packagemanager的实例 PackageManager packageManager = getPackageManager(); // getPackageName()是你当前类的包名,0代表是获取版本信息 PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0); String version = packInfo.versionName; return version; }
}
标签:android style blog color io os ar div sp
原文地址:http://www.cnblogs.com/xubuhang/p/3971155.html