My app generates kml (xml) files that I would like the user to be able to share via email, bluetooth, or whatever. I've looked at dozens of examples but am obviously still doing something wrong. If I select Gmail, the email loads properly, but the file isn't attached. If I select bluetooth, the bluetooth manager crashes. What have I done wrong here?
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[] {"testing@gmail.com"});
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"));
}