Gdy wciskam przycisk, chcę wysłać plik json wewnątrz urządzenia pocztą. Gdy przechodzę na stronę Gmail, otrzymuję komunikat o błędzie "odmowa uprawnień na załącznik". Jak mogę rozwiązać ten problem?
manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
mój kod;
sendgmailButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String filepath = "/data/data/com.example.newgen/files/jsonexample.json";
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
emailIntent.setType("application/json");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]
{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"go on read the emails");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ filepath));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
});