【发布时间】:2016-05-03 08:36:27
【问题描述】:
我想在 android 中使用 ACTION_SEND 共享图像和文本,我正在使用下面的代码,我只能共享一个图像,但我不能在远足应用程序中与它共享文本。
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
// share.setPackage("com.hike");
share.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
share.putExtra(Intent.EXTRA_TEXT, "Hello " + webView.getUrl());
/*
* if (text!=null){ share.putExtra(Intent.EXTRA_TEXT,text); } if
* (path!=null){ share.putExtra(Intent.EXTRA_STREAM,
* Uri.fromFile(new File(path))); }
*/
share.putExtra(Intent.EXTRA_STREAM, BitmapURLFromAssets.getBitmapFromAssets(MainActivity.this, "logo.png"));
try {
startActivity(Intent.createChooser(share, ""));
} catch (android.content.ActivityNotFoundException ex) {
FireToast.makeToast(MainActivity.this, "hike have not been installed.");
}
【问题讨论】:
标签: android image android-intent share