【Android性能优化】(二)高低版本兼容问题


	// 实例:http://developer.android.com/samples/BasicMediaDecoder/src/com.example.android.common.media/CameraHelper.html#l128
	/**
	 * * *
	 * 
	 * @param position
	 *            Physical position of the camera i.e
	 *            Camera.CameraInfo.CAMERA_FACING_FRONT or
	 *            Camera.CameraInfo.CAMERA_FACING_BACK.
	 * @return the default camera on the device. Returns null if camera is not
	 *         available.
	 */

	@TargetApi(Build.VERSION_CODES.GINGERBREAD) 
	private static Camera getDefaultCamera(int position) { 
		// Find the total number of cameras available 
		int mNumberOfCameras = Camera.getNumberOfCameras(); 
		// Find the ID of the back-facing ("default") 
		camera Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
		for (int i = 0; i < mNumberOfCameras; i++) { 
		Camera.getCameraInfo(i, cameraInfo); 
		if (cameraInfo.facing == position) 
		{ 
		return Camera.open(i);
		 } 
		} 
		return null; 
		}	
	
	@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
	private void setViewBackground(LinearLayout layout) {
		if (android.os.Build.VERSION.SDK_INT >= 16) {
			// 判断该版本平台上能否运行{}中的代码
			layout.setBackground(context.getResources().getDrawable(
					R.drawable.list_selector_holo_light));
		}
	}
	// Build.VERSION_CODES
	// 列举http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
	// 关键点 @TargetApi(Build.VERSION_CODES.GINGERBREAD)
	// android.os.Build.VERSION.SDK_INT >= 16


上一篇:golang copy函数


下一篇:使用BAPISDORDER_GETDETAILEDLIST创建S/4HANA的Outbound Delivery