diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/MenuHelper.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java index 17755f9..629cf87 100644 --- a/src/com/android/camera/MenuHelper.java +++ b/src/com/android/camera/MenuHelper.java @@ -21,8 +21,8 @@ import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.content.DialogInterface.OnClickListener; +import android.content.Intent; import android.net.Uri; import android.os.Environment; import android.os.StatFs; @@ -33,8 +33,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MenuItem.OnMenuItemClickListener; -import com.android.camera.R; - import java.io.Closeable; /** @@ -72,6 +70,8 @@ public class MenuHelper { public static final int RESULT_COMMON_MENU_CROP = 490; private static final int NO_ANIMATION = 0; + private static final String CAMERA_CLASS = "com.android.camera.Camera"; + private static final String VIDEO_CAMERA_CLASS = "com.android.camera.VideoCamera"; public static void closeSilently(Closeable c) { if (c != null) { @@ -122,26 +122,34 @@ public class MenuHelper { item.setIcon(iconId); } - private static void startCameraActivity(Activity activity, String action) { + private static void startCameraActivity(Activity activity, String action, + String className) { Intent intent = new Intent(action); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); + intent.setClassName(activity.getPackageName(), className); // Keep the camera instance for a while. // This avoids re-opening the camera and saves time. CameraHolder.instance().keep(); - activity.startActivity(intent); + try { + activity.startActivity(intent); + } catch (ActivityNotFoundException e) { + intent.setComponent(null); + activity.startActivity(intent); + } activity.overridePendingTransition(NO_ANIMATION, NO_ANIMATION); } public static void gotoVideoMode(Activity activity) { - startCameraActivity(activity, MediaStore.INTENT_ACTION_VIDEO_CAMERA); + startCameraActivity(activity, MediaStore.INTENT_ACTION_VIDEO_CAMERA, + VIDEO_CAMERA_CLASS); } public static void gotoCameraMode(Activity activity) { - startCameraActivity( - activity, MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); + startCameraActivity(activity, + MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA, CAMERA_CLASS); } public static void gotoCameraImageGallery(Activity activity) { |