Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash on android N #735

Merged
merged 1 commit into from
Aug 2, 2017
Merged

fix: crash on android N #735

merged 1 commit into from
Aug 2, 2017

Conversation

mayank-kgp
Copy link
Contributor

@mayank-kgp mayank-kgp commented Aug 1, 2017

Fixes #734 and #725

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Apply the MifosStyle.xml style template to your code in Android Studio.

  • Run the unit tests with ./gradlew check to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them.

@mayank-kgp
Copy link
Contributor Author

@therajanmaurya @puneetkohli521
App is crashing on android N because of android.os.FileUriExposedException
I have adapted this piece of code for resolving it.
link
I have resolved issue #725 also in this PR.
Please take a look at GIF.
issue7251

@droidchef
Copy link
Member

A better and less hacky way of doing this would be to configure a VM Policy yourself.

Here's why:
If somebody writes code that violates the file exposure in future in some other class, he'll either miss this and will have to hack this again, there by wasting time. OR He might just end up copying your code, which is bad design.

If you configure a VM policy on App Start you'll have the luxury of exploiting the fileExposure throughout the app without ever worry about it and when we migrate in future to a code level where we don't use file:// URI anymore, we'll just edit the VM Policy on app start and you won't need to change anything else anywhere.

Thanks for adding a link to the SO answer for this problem. I actually found this solution in the comment of the Top Voted Answer and when I read about, this made more sense. I'd still like to hear your thoughts, what do you think?

Here is what you'll have to do somewhere at Application onCreate to achieve what I am saying

 StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder()
     .detectFileUriExposure()
     .build();
 StrictMode.setVmPolicy(policy);

@mayank-kgp
Copy link
Contributor Author

@droidchef Thanks for your comment. But I have one doubt.
I have written this code in the onCreate of SplashScreenActivity where the app start, not in the class where the class of file uri exposure.
File Uri Exposure in happening in ClientDetailsFragment

@mayank-kgp mayank-kgp force-pushed the issue725 branch 2 times, most recently from d293625 to 15f6116 Compare August 1, 2017 18:07
@mayank-kgp
Copy link
Contributor Author

@therajanmaurya I have changed the code according to @droidchef suggestion.

@droidchef
Copy link
Member

@mayank-kgp Yes, but what is the doubt ?

@mayank-kgp
Copy link
Contributor Author

@droidchef Sorry, I misunderstood your comment. Now it's fine. :D

@droidchef
Copy link
Member

@mayank-kgp Need coffee ? Have some

image

@mayank-kgp
Copy link
Contributor Author

It's wiser to not having hot drinks in 90% humidity. :P

@droidchef
Copy link
Member

@mayank-kgp I second that !! Here you go !

image

@mayank-kgp
Copy link
Contributor Author

:P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants