FATAL EXCEPTION: main
java.lang.IllegalArgumentException: toUserId must not be null or empty
at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.call(DefaultCallClient.java:153)
at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(DefaultCallClient.java:102)
at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(DefaultCallClient.java:97)
at packagename.SinchService$SinchServiceInterface.callUser(SinchService.java:91)
at packagename.PlaceCallActivity.callButtonClicked(PlaceCallActivity.java:142)
at packagename.PlaceCallActivity.access$000(PlaceCallActivity.java:26)
at packagename.PlaceCallActivity$1.onClick(PlaceCallActivity.java:173)
at android.view.View.performClick(View.java:4802)
at android.view.View$PerformClick.run(View.java:20101)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5532)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
请详细说明可能出现的问题。我使用json解析器请求从数据库中获取随机移动号码。
private void callButtonClicked() {
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("status",status));
params.add(new BasicNameValuePair("mobile", callNo));
JSONObject json = jsonParser.makeHttpRequest(Config.URL_Random, "POST",
params);
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
response=json.getString(MOBILE);
}
}catch (JSONException e){
e.printStackTrace();
}
String userNo = response;
Log.d("Response is",userNo);
try {
Call call = getSinchServiceInterface().callUser(userNo);
if (call == null) {
// Service failed for some reason, show a Toast and abort
Toast.makeText(this, "Service is not started. Try stopping the service and starting it again before "
+ "placing a call.", Toast.LENGTH_LONG).show();
return;
}
String callId = call.getCallId();
Intent callScreen = new Intent(this, CallScreenActivity.class);
callScreen.putExtra(SinchService.CALL_ID, callId);
startActivity(callScreen);
} catch (MissingPermissionException e) {
ActivityCompat.requestPermissions(this, new String[]{e.getRequiredPermission()}, 0);
}
}
我在登录屏幕上存储用户手机号码,而callno是LoggedIn的Textview中的号码没有。这个json响应响应= json.getString(MOBILE);将从数据库中获取任何随机数。请告诉我,我在哪里做错了,我猜我的php api是由另一个存储数字给出随机数的人保证我从那边一切都很好。
答案 0 :(得分:0)
在我看来,你的数据库中有空ot null值,我们不允许emty强作为userid发送到
答案 1 :(得分:0)
尝试这个可能是因为你的callNo超出了callbuttonclicked的范围 假设你在textview中有数字,那么你在callbuttonclicked函数中执行此操作: callNo = userNo.getText()。toString();
userNo =(TextView)findViewById(R.id.number); - &GT;在onCreate方法
中执行此操作 希望能解决你的问题。