android - Api.Ai App crash -
below code on app button click crashes app.
sendbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(final view view) { string text = string.valueof(chattext.gettext()); if(text !=null && !text.isempty()){ airequest.setquery(text); } new asynctask<airequest, void, airesponse>() { @override protected airesponse doinbackground(airequest... requests) { final airequest request = requests[0]; try { final airesponse response = aidataservice.request(airequest); return response; } catch (aiserviceexception e) { } return null; } @override protected void onpostexecute(airesponse airesponse) { if (airesponse != null) { onresult(airesponse); } } }.execute(airequest); } });
i have speech listener works fine above code text query crashing app. appreciated. thank you
log
androidruntime: fatal exception: main androidruntime: process: com.example.khan.servicedeskbot, pid: 4567 androidruntime: java.lang.nullpointerexception: attempt invoke virtual method 'void ai.api.model.airequest.setquery(java.lang.string)' on null object reference androidruntime: @ com.example.khan.servicedeskbot.mainactivity$3.onclick(mainactivity.java:156) androidruntime: @ android.view.view.performclick(view.java:5610) androidruntime: @ android.view.view$performclick.run(view.java:22265) androidruntime: @ android.os.handler.handlecallback(handler.java:751) androidruntime: @ android.os.handler.dispatchmessage(handler.java:95) androidruntime: @ android.os.looper.loop(looper.java:154) androidruntime: @ android.app.activitythread.main(activitythread.java:6077) androidruntime: @ java.lang.reflect.method.invoke(native method) androidruntime: @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:866) androidruntime: @ com.android.internal.os.zygoteinit.main(zygoteinit.java:756) activitymanager: force finishing activity com.example.khan.servicedeskbot/.mainactivity
Comments
Post a Comment