Skip to content

Instantly share code, notes, and snippets.

@wannaphong
Last active February 3, 2018 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wannaphong/46d34b16501d1e3724e2d4f987bb6893 to your computer and use it in GitHub Desktop.
Save wannaphong/46d34b16501d1e3724e2d4f987bb6893 to your computer and use it in GitHub Desktop.
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
public void take(){
storage =1;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
file = new File(Environment.getExternalStorageDirectory(),
String.valueOf(System.currentTimeMillis()) + ".jpg");
//fileUri = Uri.fromFile(file);
fileUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", file);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, 1);
}
}
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment