美文网首页
那些好用的Intent

那些好用的Intent

作者: Frank_Kivi | 来源:发表于2019-01-08 14:13 被阅读7次

1.captureAudio

 PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.READ_EXTERNAL_STORAGE);
 Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION);
 startActivityForResult( this, intent, req.requestCode);

2.captureImage

PermissionHelper.requestPermissions(this, req.requestCode, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA});
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
ContentResolver contentResolver =getContentResolver();
ContentValues cv = new ContentValues();
 cv.put(MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG);
imageUri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv);
LOG.d(LOG_TAG, "Taking a picture and saving to: " + imageUri.toString());
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult((CordovaPlugin) this, intent, req.requestCode);

3.captureVideo

 PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA);
 Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
if(Build.VERSION.SDK_INT > 7){
                intent.putExtra("android.intent.extra.durationLimit", req.duration);
                intent.putExtra("android.intent.extra.videoQuality", req.quality);
}
startActivityForResult((CordovaPlugin) this, intent, req.requestCode);

相关文章

网友评论

      本文标题:那些好用的Intent

      本文链接:https://www.haomeiwen.com/subject/dawvrqtx.html