抛出异常,尽管使用正确的IP [英] Throwing exception although right IP used
本文介绍了抛出异常,尽管使用正确的IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package com.example.androidapp;
import java.net.InetSocketAddress;
import java.util.Collection;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import com.nxp.jip.JIPImpl;
import com.nxp.jip.PacketHandlerIPv6;
import com.nxp.jip.exception.JipException;
import com.nxp.jip.service.JenNetIPNetwork;
import com.nxp.jip.service.Node;
import com.nxp.jip.service.Service;
public class Application extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_application);
TextView display= (TextView) findViewById(R.id.textView2);
PacketHandlerIPv6 my_packet = new PacketHandlerIPv6();
JIPImpl my_jip = new JIPImpl(my_packet);
Service service =new Service(my_jip);
try{
JenNetIPNetwork network = service.createNetwork(new InetSocketAddress("fd04:bd3:80e8:2:215:8d00:32:54ff", 1873));
display.setText("Connected :)");
}
catch(JipException e){
display.setText("Not connected :(");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.application, menu);
return true;
}
}
虽然我正在输入正确的路由器IP,但是它会继续抛出异常,就像我输入错误的IP,并且消息未连接弹出
我没有将路由器连接到互联网
Although I am entering the right router IP it keeps throwing exception as if I am entering a wrong IP and the message "not connected" pops out And I am not connecting the router to the internet
堆栈跟踪是:
com.nxp.jip.exception.JipException: Timeout
at com.nxp.jip.CommandHandler.execute(CommandHandler.java:125)
at com.nxp.jip.JIPImpl.get(JIPImpl.java:129)
at com.nxp.jip.service.Service.createNetwork(Service.java:272)
at com.example.androidapp.Application.onCreate(Application.java:32)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
at dalvik.system.NativeStart.main(Native Method)
推荐答案
您是否尝试在清单文件中添加Internet权限,如果不添加
Have you tried adding Internet Permission in the manifest file, if not add
<uses-permission android:name="android.permission.INTERNET" />
这篇关于抛出异常,尽管使用正确的IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文