2
我的應用程序生成的kml(xml)文件,我希望用戶能夠通過電子郵件,藍牙或任何其他方式共享。我看過幾十個例子,但顯然仍然在做錯事。如果我選擇Gmail,則電子郵件會正確加載,但文件未附加。如果我選擇藍牙,藍牙管理器會崩潰。我在這裏做錯了什麼?Android:無法正確創建分享kml(xml)文件的意圖
private void createShareIntent(String filename) {
Log.d(Common.APP_TAG, "** Create share intent **");
String mime = "text/plain";
File exportFile = new File(filename);
Log.d(Common.APP_TAG, Uri.fromFile(exportFile).toString());
// logcat says : file:///mnt/sdcard/Android/data/com.gmail.qkzoo1978.qwhereami/files/exports/qExport_11-6-2012_1648.kml
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Test");
intent.putExtra(Intent.EXTRA_TEXT, "Text");
intent.setType(mime);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(exportFile));
//intent.setDataAndType(Uri.fromFile(exportFile), mime);
startActivity(Intent.createChooser(intent, "Share Kml"));
}
您是否嘗試過在數據文件夾之外選擇文件? Android的可能不會給你的權限從那裏讀 – dymmeh
http://stackoverflow.com/questions/587917/trying-to-attach-a-file-from-sd-card-to-email [此線索] [1]有很多有用的信息。 [1]:http://stackoverflow.com/questions/587917/trying-to-attach-a-file-from-sd-card-to-email –
我還沒有以相同的嘗試文件在其他地方,但它讓我在這裏讀/寫,這個應用程序創建了這個文件。上面的目錄是我的SD卡上的apps目錄。 – qkzoo1978