在向Google Plus发送邀请请求
后,未在onActivityResult()中收到回调public void sendGooglePlusInvite(){
Intent intent = new AppInviteInvitation.IntentBuilder(getActivity().getString(R.string.app_name))
.setMessage(getActivity().getString(R.string.invite_message_less))
.setCustomImage(Uri.parse(getActivity().getString(R.string.app_image_url)))
.build();
getActivity().startActivityForResult(intent, REQUEST_INVITE);
}
回电
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (resultCode == getActivity().RESULT_OK) {
if (requestCode == REQUEST_INVITE) {
// Get the invitation IDs of all sent messages
String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
for (String id : ids) {
Log.d("TAG", "onActivityResult: sent invitation " + id);
}
}
} else {
// Sending failed or it was canceled, show failure message to the user
// ...
}
}
请帮帮我
答案 0 :(得分:0)
是的,您无法通过这种方式接听回电:
要在片段中显示结果,请务必在片段中调用startActivityForResult(intent,REQUEST_INVITE);
而不是getActivity().startActivityForResult(intent,REQUEST_INVITE);
。
其次请确保在您的活动中实施此方法:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
这将调用您的片段onActivityResult()