我正在构建一个包含第三方Android Lib的Codename One应用程序。这意味着使用NativeInterface。第三方lib是sreaderautolib_v1.1.jar。在Android上用于使用声音端口通信到磁条阅读器。
我可以构建它(将其发送到CN1服务器)并将其安装在我的手机上,但在某一行之后继续获取Nullpointer。 我认为我对如何在CN1上实现NativeInterfaces的理解是缺乏的,它与代码有关,但我看不出错误。
请帮助!!
滑动:
package co.za.jaco.swiperapp.components;
import com.codename1.system.NativeInterface;
public interface Swipe extends NativeInterface {
public boolean Init();
public boolean isInit();
public void Start();
public void Stop();
public void SetMute(boolean mute);
public String GetErrorString();
public boolean Initial(long millis);
public String GetVersion(long millis);
public String GetKSN(long millis);
public String GetRandom(long millis);
public String ReadCard(long millis);
public String GetT1PAN(long millis);
public String GetT1HolderName_Exd(long millis);
public String GetT2PAN(long millis);
public String GetT2Exd(long millis);
public void Cancel();
public String GenerateWorkingKey(String random, String ksn);
public String TriDesDecryption(String dnc_key, String en_data);
}
SwipeImpl:
package co.za.jaco.swiperapp.components;
public class SwipeImpl {
private com.singular.hijack.autofreq.SReaderApi getSreaderInstance(){
return com.singular.hijack.autofreq.SReaderApi.getSreaderInstance();
}
public void Start() {
getSreaderInstance().Start();
}
public void Cancel() {
getSreaderInstance().Cancel();
}
public void Stop() {
getSreaderInstance().Stop();
}
public boolean Init() {
return getSreaderInstance().Init();
}
public boolean isInit() {
return getSreaderInstance().isInit();
}
public void SetMute(boolean param) {
getSreaderInstance().SetMute(param);
}
public String GetErrorString() {
return getSreaderInstance().GetErrorString();
}
public boolean Initial(long param) {
return getSreaderInstance().Initial(param);
}
public String GetVersion(long param) {
return getSreaderInstance().GetVersion(param);
}
public String GetKSN(long param) {
return getSreaderInstance().GetKSN(param);
}
public String GetRandom(long param) {
return getSreaderInstance().GetRandom(param);
}
public String ReadCard(long param) {
return getSreaderInstance().ReadCard(param);
}
public String GetT1PAN(long param) {
return getSreaderInstance().GetT1PAN(param);
}
public String GetT1HolderName_Exd(long param) {
return getSreaderInstance().GetT1HolderName_Exd(param);
}
public String GetT2PAN(long param) {
return getSreaderInstance().GetT2PAN(param);
}
public String GetT2Exd(long param) {
return getSreaderInstance().GetT2Exd(param);
}
public String GenerateWorkingKey(String param, String param1) {
return getSreaderInstance().GenerateWorkingKey(param,param1);
}
public String TriDesDecryption(String param, String param1) {
return getSreaderInstance().TriDesDecryption(param,param1);
}
public boolean isSupported() {
return true;
}
}
StateMachine:
Swipe swipe = (Swipe) NativeLookup.create(Swipe.class);
appendText("swipe.obj == null :" + (swipe == null));//says false
boolean bool = swipe.Initial(2500); **//THROW NULLPOINTER**
appendText("swipe.Initial(2500):" + bool);
boolean bool2 = swipe.isInit();
appendText("swipe.isInit():" + bool2);
答案 0 :(得分:0)
我猜getSreaderInstance()
返回null。我建议通过DDMS连接设备,并在控制台中获取异常的完整堆栈跟踪。