File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222 </intent-filter >
2323 </activity >
2424
25+ <provider
26+ android : name =" android.support.v4.content.FileProvider"
27+ android : authorities =" ${applicationId}"
28+ android : exported =" false"
29+ android : grantUriPermissions =" true" >
30+ <meta-data
31+ android : name =" android.support.FILE_PROVIDER_PATHS"
32+ android : resource =" @xml/paths" />
33+ </provider >
34+
2535 </application >
2636
2737</manifest >
Original file line number Diff line number Diff line change 2323import android .os .AsyncTask ;
2424import android .os .Bundle ;
2525import android .preference .PreferenceManager ;
26+ import android .support .v4 .content .FileProvider ;
2627import android .support .v7 .app .AlertDialog ;
2728import android .support .v7 .app .AppCompatActivity ;
2829import android .support .v7 .widget .DefaultItemAnimator ;
@@ -182,11 +183,12 @@ private Intent getShareIntent() {
182183 Log .w (TAG , e );
183184 }
184185
185- Uri uri = Uri . fromFile ( new File ( getExternalCacheDir () + TEMP_FILE ) );
186+ Uri uri = FileProvider . getUriForFile ( this , getPackageName (), file );
186187
187188 Intent intent = new Intent (Intent .ACTION_SEND );
188- intent .setType ("text/plain " );
189+ intent .setType ("text/* " );
189190 intent .putExtra (Intent .EXTRA_STREAM , uri );
191+ intent .addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
190192 return intent ;
191193 }
192194
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <paths >
3+ <external-cache-path name =" share_path" path =" ." />
4+ </paths >
You can’t perform that action at this time.
0 commit comments