Skip to content

Instantly share code, notes, and snippets.

@tuttelikz
Created May 25, 2018 04:03
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 tuttelikz/e4776a57c4063b366069ae750768aebc to your computer and use it in GitHub Desktop.
Save tuttelikz/e4776a57c4063b366069ae750768aebc to your computer and use it in GitHub Desktop.
The following lines show which permissions to define for resolving some of the errors in Android.
// Solves this mentioned error:
// android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()
// Inside Manifest, define following permissions:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
// Inside onCreate method of Activity:
// Disable the detection of everything.
verifyStoragePermissions(this);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// Creates StrictMode.VmPolicy instances.
// For example, detect everything and log anything that's found:
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment