我想创建一个与默认相机应用程序相同的应用程序,仅进行一点小修改(即禁用视频或添加额外功能)。我该怎么做?
我是直接获取相机应用程序的源代码并对其进行修改,还是有办法扩展 Android 系统的核心组件?
最佳答案
bizso99,
您可以从您的 Activity
调用一个 Intent
,它只是相机无视频功能,如下所示:
public void imageFromCamera() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);
}
这将返回图像的较小缩略图版本。如果你想要全尺寸,你需要像这样使用 Mediastore.EXTRA_OUTPUT
:
public void imageFromCamera() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
mImageFile = new File(pathToStoreImage); //file where image will be stored
mSelectedImagePath = mImageFile.getAbsolutePath(); //path to file where image will be stored
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
startActivityForResult(intent, TAKE_PICTURE);
}
然后就可以在onActivityResult()
中接收到图片了
关于android - 扩展安卓应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4937191/