这是我绑定的代码:
public void bindService() {
Log.i("Bind service:", "Starting");
serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
microRuntimeService = (MicroRuntimeServiceBinder) service;
Properties pp = new Properties();
pp.setProperty(Profile.MAIN_HOST, "192.168.1.5");
pp.setProperty(Profile.MAIN_PORT, "1099");
pp.setProperty(Profile.JVM, Profile.ANDROID);
Log.i("Bind service:", "Properties Set");
microRuntimeService.startAgentContainer(pp, new RuntimeCallback<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Split container startup successfull
Toast.makeText(MapsActivity.this, "Container created", Toast.LENGTH_LONG).show();
Log.i("Bind service:", "Container creation");
microRuntimeService.startAgent(nickname, AndroidAgent.class.getName(), new Object[]{getApplicationContext()}, new RuntimeCallback<Void>() {
@Override
public void onSuccess(Void aVoid) {
//Agent succesfully started
Toast.makeText(MapsActivity.this, "Agent created", Toast.LENGTH_LONG).show();
Log.i("Bind service:", "Success");
}
@Override
public void onFailure(Throwable throwable) {
//Agent startup error
Toast.makeText(MapsActivity.this, "Agent creation error", Toast.LENGTH_LONG).show();
Log.e("Bind service:", "Agent startup error");
}
});
}
@Override
public void onFailure(Throwable throwable) {
// Split container startup error
Toast.makeText(MapsActivity.this, "Container failure", Toast.LENGTH_LONG).show();
Log.e("Bind service:", "Split container startup error");
}
});
;
}
@Override
public void onServiceDisconnected(ComponentName name) {
microRuntimeService = null;
}
};
bindService(new Intent(getApplicationContext(), MicroRuntimeService.class), serviceConnection, Context.BIND_AUTO_CREATE);
Log.i("Bind service:", "Binding");
}
代码有效 - 我知道因为我的朋友使用过它但在我的情况下我的设备总是属于这种方法:
@Override
public void onFailure(Throwable throwable) {
// Split container startup error
这是它显示的例外情况:
jade.imtp.leap.JICP.BIFEDispatcher: Connection error. java.net.ConnectException: failed to connect to /192.168.1.5 (port 1099): connect failed: ETIMEDOUT (Connection timed out)
09-07 23:06:38.938 19618-20812/com.example.aleksander.localizer E/jade.core.FrontEndContainer: IMTP error jade.core.IMTPException: Error creating the BackEnd.
09-07 23:06:38.940 19618-20812/com.example.aleksander.localizer W/System.err: jade.core.IMTPException: Error creating the BackEnd.
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err: at jade.imtp.leap.JICP.BIFEDispatcher.createBackEnd(BIFEDispatcher.java:292)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err: at jade.imtp.leap.JICP.BIFEDispatcher.getBackEnd(BIFEDispatcher.java:191)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err: at jade.core.BackEndWrapper.attach(BackEndWrapper.java:142)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err: at jade.core.BackEndWrapper.<init>(BackEndWrapper.java:86)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err: at jade.core.FrontEndContainer.start(FrontEndContainer.java:149)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err: at jade.core.MicroRuntime.startJADE(MicroRuntime.java:128)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err: at jade.android.MicroRuntimeService$1.run(MicroRuntimeService.java:172)
09-07 23:06:38.944 19618-20812/com.example.aleksander.localizer I/jade.android.RuntimeService: Cannot create micro agent container with message: Cannot connect to the platform at 192.168.1.5:1099
是我的路由器还是我的代码?
请帮忙。