我在尝试从活动外部使用calcularRuta方法时遇到问题。该方法根据其输入返回一个值。我无法获得任何结果,因为我尝试过调试它,它甚至没有输入该方法,所以当我必须在下一行中使用变量ruta时,它是空的。
public boolean onTouch(View v, MotionEvent event) {
try {
String qr = DecodeQR.zxing(mRgba);
int origen = Integer.valueOf(qr);
int destino = Integer.valueOf(bundle.getString("DESTINO"));
boolean ascensor = bundle.getBoolean("ASCENSOR");
if (ruta == null)
ruta = IniciarBusqueda.calcularRuta(origen, destino, ascensor);
updateScreen(qr, ruta.toString());
} catch (ChecksumException e) {
e.printStackTrace();
} catch (FormatException e) {
e.printStackTrace();
}
return false;
}我想找出问题出在哪里,但我不能.有什么想法吗?
谢谢。
编辑:将实用程序方法更改为静态方法。
发布于 2014-05-20 08:53:33
1)不应该实例化一个活动。
2)将该方法设置为public static,以便您可以使用Classname.methodName访问它。不需要实例化类。
https://stackoverflow.com/questions/23755012
复制相似问题