我使用此代码,但它无法正常工作.
String Body = "Deals Name: " + Bussinessname + "\n" + "Deals: " + deal + "\n" + "Address: " + city + "," + country; Intent share = new Intent(android.content.Intent.ACTION_SEND); Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + image); share.setType("image/*"); share.putExtra(Intent.EXTRA_SUBJECT,"The EssexPass"); share.putExtra(Intent.EXTRA_TEXT,Body); share.putExtra(Intent.EXTRA_STREAM,screenshotUri); startActivity(Intent.createChooser(share,"Share Deal"));
解决方法
试试下面的代码:
String fileName = "image-3116.jpg";//Name of an image String externalStorageDirectory = Environment.getExternalStorageDirectory().toString(); String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images Uri uri = Uri.parse("file:///" + myDir + fileName); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/html"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Mail"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Launcher"); shareIntent.putExtra(Intent.EXTRA_STREAM,uri); startActivity(Intent.createChooser(shareIntent,"Share Deal"));