I'm developing a PhoneGap application using Javascript to communicate with Java. I'm trying to access a class called RcpApi2 within a JAR file called A100_AL1001-23_AndroidLibrary.jar, but when I try to access the functions within I get this error:
Cannot make a static reference to the non-static method startReadTagsWithRssi(int, int, int) from the type RcpApi2
The errors occur when I try to access these methods:
- RcpApi2.open();
- RcpApi2.isopen;
- RcpApi2.startReadTagsWithRssi(...);
Does anyone know why this is happening/how to fix this?
Project Directories:
Java Code:
import com.phychips.rcp.*;
public class HelloPlugin extends Plugin implements iRcpEvent2 {
public static final String KEY_ENCODING = "my_encoding";
public static final String KEY_SAVELOG = "my_saveLog";
public static final String NATIVE_ACTION_STRING="nativeAction";
public static final String SUCCESS_PARAMETER="success";
...
public PluginResult execute(String action, JSONArray dataArray, String callbackId) {
if (NATIVE_ACTION_STRING.equals(action)) {
String resultType = null;
try {
resultType = dataArray.getString(0);
}
catch (Exception ex) {
Log.d("HelloPlugin", ex.toString());
}
if (resultType.equals(SUCCESS_PARAMETER)) {
RcpApi2.getInstance().setOnRcpEventListener(this);
try {
RcpApi2.open();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (RcpApi2.isOpen)
{
try {
boolean k = RcpApi2.startReadTagsWithRssi(maxTags, maxTime, repeatCycle);
return new PluginResult(PluginResult.Status.OK, "Yay, Success!!!");
} catch (RcpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Jar File Code:
public class RcpApi2 extends BroadcastReceiver {
private boolean isOpen = false;
public boolean open() throws Exception {
init(mIoType);
readerIo.open();
isOpen = true;
}
public boolean isOpen() {
return this.isOpen;
}
public boolean startReadTagsWithRssi(int maxTags, int maxTime, int repeatCycle) {
RcpPacket rcpPacket = RcpPacket.getInstance();
if (!this.mIRcp.startReadTagsWithRssi(rcpPacket, maxTags, maxTime, repeatCycle)) {
return false;
}
boolean ret = true;
...
return ret;
}
}