mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Use fileProvider instead of Uri.fromFile() * As Uri.fromFile() will not work on Android 7.0+, with a targetSdkVersion of 24 or higher, throws FileUriExposedException
This commit is contained in:
parent
5a9cce0f79
commit
b244e403c2
3 changed files with 7 additions and 2 deletions
|
|
@ -31,6 +31,7 @@
|
|||
android:largeHeap="true"
|
||||
android:hardwareAccelerated="false"
|
||||
android:supportsRtl="true" >
|
||||
|
||||
<activity android:name="org.acra.CrashReportDialog"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:launchMode="singleInstance"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.graphics.drawable.BitmapDrawable;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
|
@ -184,13 +185,15 @@ public class AchievementsActivity extends NavigationBaseActivity {
|
|||
fOut.flush();
|
||||
fOut.close();
|
||||
file.setReadable(true, false);
|
||||
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), getPackageName()+".provider", file);
|
||||
grantUriPermission(getPackageName(), fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||
intent.setType("image/png");
|
||||
startActivity(Intent.createChooser(intent, "Share image via"));
|
||||
} catch (IOException e) {
|
||||
//Do Nothing
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@
|
|||
<cache-path name="images" path="images/" />
|
||||
<external-path name="Download" path="./"/>
|
||||
<root-path name="root" path="." />
|
||||
<external-cache-path name="external_cache_path" path="."/>
|
||||
</paths>
|
||||
Loading…
Add table
Add a link
Reference in a new issue