获取系统版本&获取手机分辨率
//
/**获取手机各种信息**/ String phoneInfo = "Product: " + android.os.Build.PRODUCT; phoneInfo += ", CPU_ABI: " + android.os.Build.CPU_ABI; phoneInfo += ", TAGS: " + android.os.Build.TAGS; phoneInfo += ", VERSION_CODES.BASE: " + android.os.Build.VERSION_CODES.BASE; phoneInfo += ", MODEL: " + android.os.Build.MODEL; phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK; phoneInfo += ", VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE; phoneInfo += ", DEVICE: " + android.os.Build.DEVICE; phoneInfo += ", DISPLAY: " + android.os.Build.DISPLAY; phoneInfo += ", BRAND: " + android.os.Build.BRAND; phoneInfo += ", BOARD: " + android.os.Build.BOARD; phoneInfo += ", FINGERPRINT: " + android.os.Build.FINGERPRINT; phoneInfo += ", ID: " + android.os.Build.ID; phoneInfo += ", MANUFACTURER: " + android.os.Build.MANUFACTURER; phoneInfo += ", USER: " + android.os.Build.USER; // Toast.makeText(this, phoneInfo, Toast.LENGTH_LONG).show(); TextView t = (TextView) findViewById(R.id.main_phoneinfo); t.setText(phoneInfo);
获取手机分辨率 private TextView textView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String string = "手机屏幕分辨率为:" + displayMetrics.widthPixels + "x" + displayMetrics.heightPixels; textView = (TextView) findViewById(R.id.textView); textView.setText(string); }
Application用于获取一些全局数据,各种Activity,Adapter,View等都可用的数据,使用时一般创建MyApplication子类,
调用时用Activity的getApplication方法,
(MyApplication)getApplication.killPrice(str)
在View中:
((MyApplication)getContext().getApplicationContext()).getScore()