I am trying to make a chat application demo in android using quickblox,I have got a list of users successfully,and on click of usrlist i got its "id",I pass it to creating new chat dialog code,But it gives me Nullpointer at privatechatmanager.
my code is :
public Integer getOpponentIDForPrivateDialog(QBDialog dialog){
Integer opponentID = -1;
for(Integer userID : dialog.getOccupants()){
if(!userID.equals(getCurrentUser().getId())){
opponentID = userID;
break;
}
}
return opponentID;
}
logcat 06-16 17:11:07.817:
I/System.out(32408): =============MY SELECTED USER==============3588999
06-16 17:11:07.847: D/AndroidRuntime(32408): Shutting down VM
06-16 17:11:07.847: W/dalvikvm(32408): threadid=1: thread exiting with uncaught exception (group=0x418a3da0)
06-16 17:11:07.847: E/AndroidRuntime(32408): FATAL EXCEPTION: main
06-16 17:11:07.847: E/AndroidRuntime(32408): Process: com.amar.chums, PID: 32408
06-16 17:11:07.847: E/AndroidRuntime(32408): java.lang.NullPointerException
06-16 17:11:07.847: E/AndroidRuntime(32408): at com.amar.chums.activity.ManageConnection$2.onItemClick(ManageConnection.java:154)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.widget.AdapterView.performItemClick(AdapterView.java:313)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.widget.AbsListView.performItemClick(AbsListView.java:1507)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3514)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.widget.AbsListView$3.run(AbsListView.java:5072)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.os.Handler.handleCallback(Handler.java:733)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.os.Handler.dispatchMessage(Handler.java:95)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.os.Looper.loop(Looper.java:146)
06-16 17:11:07.847: E/AndroidRuntime(32408): at android.app.ActivityThread.main(ActivityThread.java:5653)
06-16 17:11:07.847: E/AndroidRuntime(32408): at java.lang.reflect.Method.invokeNative(Native Method)
06-16 17:11:07.847: E/AndroidRuntime(32408): at java.lang.reflect.Method.invoke(Method.java:515)
06-16 17:11:07.847: E/AndroidRuntime(32408): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
06-16 17:11:07.847: E/AndroidRuntime(32408): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
06-16 17:11:07.847: E/AndroidRuntime(32408): at dalvik.system.NativeStart.main(Native Method)
Please help me to save my life..!!!
try to handle the nullpointer