編輯:關於Android編程
有部分手機的影像是倒立的,如何解決這個問題呢? 請看下面
public static void setCameraDisplayOrientation(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay()
.getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
case Surface.ROTATION_180: degrees = 180; break;
case Surface.ROTATION_270: degrees = 270; break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
camera.setDisplayOrientation(result);
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
setCameraDisplayOrientation(this,0,camera)
}
android 在surfaceView上畫圖
為了在SurfaceView上畫圖,我們定義一個MySurfaceView類,該類繼承SurfaceView並且實現SurfaceHolder.Callback接口。在s
jadx 反編譯apk
引子承接我的上一篇文章Android ClassyShark vs ApkTool,感謝讀者@weishu的提醒,jadx是我遺漏的一個非常好用的android反編譯gu
Android 游戲開發入門簡單示例
在Android系統上開發游戲是Android開發學習者所向往的,有成就感也有樂趣,還能取得經濟上的報酬。那怎樣開發Android游戲呢?下面介紹一個簡單的入
Android游戲開發:實現手勢操作切換圖片的實例
對於Android 的手勢不光在軟件中會經常用到,比如浏覽器中的翻頁,滾動頁面等等;當然其實在我