2017-11-06 3 views
1

私はAndroid 23 API用quickbloxを使用しています。コールが確立される直前に、ある発信者から別の発信者にユーザー情報を含める必要があります。 私はQBRTCSessionの 'userinfo'部分を使用し、キー値のペアを入れました。しかし、もう片方のために、それは 'userinfo'にヌル値を与えます。誰でも可能な理由を示唆して解決策を提案してもらえますか?QuickBlox android session userinfo is null

セッションIDは両方の呼び出しで同じです。 IncomeCallFragmentで

public void onReceiveNewSession(final QBRTCSession session) { 
    Log.d("userinfo_needed", "Session " + session.getSessionID() + " are income"); 
    Log.v("qbrtcsession",session.getSessionDescription().toString()); 
    userInfo = session.getUserInfo(); 
    if (getCurrentSession() != null) { 
     //userInfo = session.getUserInfo(); 
     Log.d(TAG, "Stop new session. Device now is busy"); 
     session.rejectCall(null); 
    } 
} 

アクティビティ - コールで

private void startCall(boolean isVideoCall) { 
    if (opponentsAdapter.getSelectedItems().size() > Consts.MAX_OPPONENTS_COUNT) { 
     Toaster.longToast(String.format(getString(R.string.error_max_opponents_count), 
       Consts.MAX_OPPONENTS_COUNT)); 
     return; 
    } 
    Log.d(TAG 
      , "startCall()"); 
    //ArrayList<Integer> opponentsList = CollectionsUtils.getIdsSelectedOpponents(opponentsAdapter.getSelectedItems()); 
    ArrayList<Integer> opponentsList = new ArrayList<>(); 
    opponentsList.add(currentOpponentsList.get(0).getId()); 
    QBRTCTypes.QBConferenceType conferenceType = isVideoCall 
      ? QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_VIDEO 
      : QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_AUDIO; 
    QBRTCClient qbrtcClient = QBRTCClient.getInstance(getApplicationContext()); 
    QBRTCSession newQbRtcSession = qbrtcClient.createNewSessionWithOpponents(opponentsList, conferenceType); 
    newQbRtcSession.getUserInfo().put("som","name"); 
    Log.v("SessionThing",newQbRtcSession.getSessionDescription().toString()); 

    WebRtcSessionManager.getInstance(this).setCurrentSession(newQbRtcSession); 
// newQbRtcSession. 

    PushNotificationSender.sendPushMessage(opponentsList, "Hello"+currentUser.getFullName()); 
    Toast.makeText(getApplicationContext(),name,Toast.LENGTH_LONG).show(); 
    CallActivity.start(this, false); 

    Log.d(TAG, "conferenceType = " + conferenceType); 
} 

機能 - コールを開始 - あなたは、セッションが開始呼び出しのセッションに地図を設定して作成するとトーストがnull

private void initUI(View view) { 
    callTypeTextView = (TextView) view.findViewById(R.id.call_type); 

    ImageView callerAvatarImageView = (ImageView) view.findViewById(R.id.image_caller_avatar); 
    callerAvatarImageView.setBackgroundDrawable(getBackgroundForCallerAvatar(currentSession.getCallerID())); 

    TextView callerNameTextView = (TextView) view.findViewById(R.id.text_caller_name); 

    QBUser callerUser = qbUserDbManager.getUserById(currentSession.getCallerID()); 
    callerNameTextView.setText(UsersUtils.getUserNameOrId(callerUser, currentSession.getCallerID())); 
    Toast.makeText(getActivity().getApplicationContext(),currentSession.getSessionDescription().getUserInfo()+" ", Toast.LENGTH_LONG).show(); 
    TextView otherIncUsersTextView = (TextView) view.findViewById(R.id.text_other_inc_users); 
    otherIncUsersTextView.setText(getOtherIncUsersNames()); 

    alsoOnCallText = (TextView) view.findViewById(R.id.text_also_on_call); 
    setVisibilityAlsoOnCallTextView(); 

    rejectButton = (ImageButton) view.findViewById(R.id.image_button_reject_call); 
    takeButton = (ImageButton) view.findViewById(R.id.image_button_accept_call); 
    accept(); 
} 
+0

ここで、session.startcall()を呼び出しています。 – ADM

+0

あなたは答えを得ましたか? –

+0

@ user2828360どんな解決策がありましたか?返信してください –

答えて

1

を与えます:

public static Map<String,String> createSessionUserInfo(){ 
    // Make sure you do not add anything null in this Map. Otherwise it will throw Exception, 
    // So add blank string instead of null 
    Map<String,String> userInfo=new HashMap<>(); 
    userInfo.put("img_user" , "img_url_here"); 
    userInfo.put("name_user" , "name_here"); 
    return userInfo; 
} 

はその後、コールを開始するためにこの情報を追加:あなたはonReceiveNewSession(でこのセッションを受ける相手側では

Map<String,String> userInfo= createSessionUserInfo(); 
      currentCallSession.startCall(userInfo); 

)をし、そのデフォルトの動作:

@Override 
public void onReceiveNewSession(final QBRTCSession qbrtcSession) { 
    try { 
     Map<String, String> userSessionInfo = qbrtcSession.getUserInfo(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

あなたがまだあるなら、私を知ってみましょう直面する問題。

+0

私たちはそれを試みたが、まだ動作していない、それもそのようなonReceiveNewSession()メソッドを呼び出すようだ。これは私たちの最初の呼び出しです。 QBRTCSession newQbRtcSession = qbrtcClient.createNewSessionWithOpponents(opponentsList、conferenceType); Map userinfo = new HashMap <>(); userinfo.put( "a"、name); newQbRtcSession.startCall(userinfo); WebRtcSessionManager.getInstance(this).setCurrentSession(newQbRtcSession); Quickbloxによるビデオのサンプルアプリケーションを使用しています。 – user2828360

+0

あなたがマップに渡している名前がヌルか空白でないことを確かめてください。コードで質問を編集してください。 – ADM

+0

質問を更新しました – user2828360