requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
但是注意要在SetContentView()前进行设置。
2.设置背景常量
在View的onCreate函数中
setKeepScreenOn(true);//设置背景常亮
在Activity中
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
3.如何使用Dialog形式的Activity以及禁止屏幕自动翻转
<activity android:name=".PassDialog" android:label="You Win!"
android:theme="@android:style/Theme.Dialog"
android:screenOrientation="portrait">
android:screenOrientation="landscape",设置完后,表示屏幕设置为横屏,如果设置为“portrait”就为竖屏。
4. Map功能的URI
"GoogleMap" - .setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
"Brut" - i.setClassName("brut.googlemaps",
"com.google.android.maps.MapsActivity");
"Mapbar" - i.setClassName("com.mapbar.android.maps",
"com.mapbar.android.maps.OutCallMapViewActivity");
"MiniMap" - i = new Intent("com.autonavi.minimap.ACTION",
Uri.parse(sb.toString()));
5. 获取当前的系统时间
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
+ ".jpg";
6. Camera拍照并存储
imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
imageCaptureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
7.从手机中获取图片
private void galleryMethod() {
strImgPath = "";
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
2);
}
8.获取手机型号和版本信息
textView.setText("Product Model: " + android.os.Build.MODEL + ","
+ android.os.Build.VERSION.SDK + ","
+ android.os.Build.VERSION.RELEASE);
9.获取屏幕大小的2种方法
int screenWidth, screenHeight;
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
或者
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
10.
11.