当共享弹出窗口出现时,我在 WhatsApp 上成功共享了内容,但仍然返回 RESULT_CANCELLED。当我使用 Gmail 发送电子邮件时,结果相同。
调用共享意图,ACTION_SEND
总是startActivityForResult
返回CANCELLED
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TITLE, "Taxeeta, Cab Around The Curb");
sharingIntent
.putExtra(
android.content.Intent.EXTRA_TEXT,
"Hiring a cab no longer needs you to wait on call centers, or pay a"
+ " convenience (yeah right!!) charge. Taxeeta connects you"
+ " to drivers directly, for a quick book experience. With Taxeeta"
+ " you can take matters in your own hands (literally). To download"
+ " the app for your phone visit http://www.taxeeta.com");
startActivityForResult(Intent.createChooser(sharingIntent, "Share and earn a extra Priviledge"), 111);
ActivityForResult 代码
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 111) {
if (resultCode == RESULT_OK) {
Toast.makeText(this, "Ok DUDE", Toast.LENGTH_LONG).show();
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Oversmart Eh!!", Toast.LENGTH_LONG).show();
}
}
}