Atunci când am apăsați butonul, vreau să trimit fișierul json în interiorul dispozitivului prin e-mail. Atunci când fac trecerea de la Gmail parte, primesc eroarea "permission denied de atașament". Cum pot rezolva aceasta problema?
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" />
codul meu;
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..."));
}
});