diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-09-28 20:04:49 -0700 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-09-28 20:37:40 -0700 |
commit | 12a37600880bacb5207520eb74a857a75e2cddef (patch) | |
tree | 35661338171bf2e3b9dd573320d30612a9f0d953 /src | |
parent | 141e3cc66815fafce690c889269a30ce7e06c4da (diff) | |
download | LegacyCamera-12a37600880bacb5207520eb74a857a75e2cddef.zip LegacyCamera-12a37600880bacb5207520eb74a857a75e2cddef.tar.gz LegacyCamera-12a37600880bacb5207520eb74a857a75e2cddef.tar.bz2 |
Hardcode package/class to switch between camera and camcorder.
Users do not expect to choose other camera applications when they
slide the switch. If the activity is not found, fallback to the
intent without package and class names.
bug:3023951
Change-Id: Ifbd9916699255bffdc0cdfb50ed650ad26349dc4
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) { |