Když jsem stiskněte tlačítko, chci poslat json soubor dovnitř zařízení přes mail. Když jsem se přejít na Gmail straně, dostanu chybu "přístup odepřen pro přílohu". Jak mohu tento problém vyřešit?
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 kód;
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..."));
}
});