怎样设置Activity只有竖屏模式?
在Android Manifest 文件中添加如下代码:
android:screenOrientation="portrait"
怎样判断当前是横屏模式还是竖屏模式?
public static boolean isScreenChange(Context mContext) { Configuration mConfiguration = mContext.getResources().getConfiguration(); int ori = mConfiguration.orientation; if(ori == mConfiguration.ORIENTATION_LANDSCAPE) { return true; }else if(ori == mConfiguration.ORIENTATION_PORTRAIT) { return false; } return false; }
获取设备的版本和Api Level?
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar mActionBar = getActionBar(); mActionBar.setSubtitle("J is testing for build version target"); } int version = android.provider.Settings.System.getInt(this.getContentResolver(), android.provider.Settings.System.SYS_PROP_SETTING_VERSION, 3); Toast.makeText(this, version + "", Toast.LENGTH_SHORT).show();
TBD...
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.