List of usage examples for android.support.v4.app Fragment getActivity
public Activity getActivity()
From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java
/** * ??// ww w . j a v a 2s . c o m * * @param fragment * @param jsonObject * @param requestCode */ public static void startRedPacketActivityForResult(Fragment fragment, com.alibaba.fastjson.JSONObject jsonObject, int requestCode) { RedPacketInfo redPacketInfo = new RedPacketInfo(); redPacketInfo.fromAvatarUrl = jsonObject.getString(RedPacketConstant.KEY_FROM_AVATAR_URL); Intent intent = new Intent(fragment.getActivity(), SendingRedBagActivity.class); redPacketInfo.fromNickName = jsonObject.getString(RedPacketConstant.KEY_FROM_NICK_NAME); //IdId int chatType = jsonObject.getInteger(RedPacketConstant.KEY_CHAT_TYPE); if (chatType == 1) { redPacketInfo.toUserId = jsonObject.getString(RedPacketConstant.KEY_USER_ID); redPacketInfo.chatType = 1; intent.putExtra("type", 0); intent.putExtra("isGroup", "0"); } else if (chatType == 2) { redPacketInfo.toGroupId = jsonObject.getString(RedPacketConstant.KEY_GROUP_ID); redPacketInfo.groupMemberCount = jsonObject.getInteger(RedPacketConstant.KEY_GROUP_MEMBERS_COUNT); redPacketInfo.chatType = 2; intent.putExtra("type", 1); intent.putExtra("isGroup", "1"); intent.putExtra(RedPacketConstant.KEY_GROUP_ID, redPacketInfo.toGroupId); } intent.putExtra("fromchat", true); intent.putExtra(RPConstant.EXTRA_RED_PACKET_INFO, redPacketInfo); fragment.startActivityForResult(intent, requestCode); }