Ich versuche, eine Bilddatei mit "openFileOutput" zu speichern und dann diese Datei mit EXTRA_STREAM zu meiner Absicht hinzufügen. aber logcat sagt, dass die Dateigröße 0 ist, ich habe die richtige Erlaubnis in meinem Manifest.Android FileOutputStream
FileOutputStream fos = openFileOutput("p001.jpg", Context.MODE_WORLD_READABLE);
File jpg = getFileStreamPath("p001.jpg");
fos.close();
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_SUBJECT, "Fail picture");
share.putExtra(Intent.EXTRA_TEXT, "Epic fail!!!");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(jpg));
startActivity(Intent.createChooser(share, "Choose share method."));
aktualisiert Code
private void HandleSMS() throws IOException {
FileOutputStream fos = openFileOutput(R.drawable.p001, Context.MODE_WORLD_READABLE);
File jpg = getFileStreamPath("p001.jpg");
fos.close();
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_SUBJECT, "Fail picture");
share.putExtra(Intent.EXTRA_TEXT, "Epic fail!!!");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(jpg));
startActivity(Intent.createChooser(share, "Choose share method."));
}
Kann den Speicherort angeben, von dem Sie versuchen, die Bilddatei abzurufen. – Sandy
in "openFileOutput (" p001.jpg "" das p001.jpg ist in .drawable. Für die uri.fromFile, ich versuche, diese Bilddatei zu holen, indem ich "getFileStreamPath (" p001.jpg ");" und das Erhalten seines Pfad – zaid