public class Blesave {
private int rssi1, rssi2, rssi3, rssi4;
private int major, minor1,minor2, minor3, minor4, txpower1,txpower2, txpower3, txpower4;
private double accuracy1, accuracy2, accuracy3, accuracy4;
private long timestamp, timeInternal;
private String uuid;
public Blesave(long timestamp, long timeInternal, String uuid, int major,
int minor1, double accuracy1, int txpower1, int rssi1,
int minor2, double accuracy2, int txpower2, int rssi2,
int minor3, double accuracy3, int txpower3, int rssi3,
int minor4, double accuracy4, int txpower4, int rssi4){
this.timestamp = timestamp;
this.timeInternal = timeInternal;
this.uuid = uuid;
this.major = major;
this.minor1 = minor1;
this.minor2 = minor2;
this.minor3 = minor3;
this.minor4 = minor4;
this.txpower1 = txpower1;
this.txpower2 = txpower2;
this.txpower3 = txpower3;
this.txpower4 = txpower4;
this.accuracy1 = accuracy1;
this.accuracy2 = accuracy2;
this.accuracy3 = accuracy3;
this.accuracy4 = accuracy4;
this.rssi1 = rssi1;
this.rssi2 = rssi2;
this.rssi3 = rssi3;
this.rssi4 = rssi4;
}
public String getDataInCSV() {
return String.format(Locale.KOREA, "%d,%d,%s,%d,%d,%f,%d,%d,%d,%f,%d,%d,%d,%f,%d,%d,%d,%f,%d,%d",
this.timestamp, this.timeInternal, this.uuid, this.major,
this.minor1, this.accuracy1,this.txpower1,this,rssi1,
this.minor2, this.accuracy2,this.txpower2,this,rssi2,
this.minor3, this.accuracy3,this.txpower3,this,rssi3,
this.minor4, this.accuracy4,this.txpower4,this,rssi4);
}
}
但是当我运行此代码时,它将显示以下错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.sensingkit.crowdsensing_android, PID: 21490
java.util.IllegalFormatConversionException: d !=
com.example.haoch.sensoring.Blesave
at
java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4135)
at
java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2832)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2786)
at java.util.Formatter.format(Formatter.java:2491)
at java.util.Formatter.format(Formatter.java:2426)
at java.lang.String.format(String.java:2670)
at com.example.haoch.sensoring.Blesave.getDataInCSV(Blesave.java:47)
at com.example.haoch.sensoring.RecoBackgroundRangingService.storeBeaconIntoCSV(RecoBackgroundRangingService.java:161)
at com.example.haoch.sensoring.RecoBackgroundRangingService.didRangeBeaconsInRegion(RecoBackgroundRangingService.java:146)
at com.perples.recosdk.a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6363)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
有人能帮助我吗?我很欣赏,我认为这是与%d问题有关的合成问题,但我不确定它在哪里?
答案 0 :(得分:0)
您的参数列表包含this,rssi1
,this,rssi2
等的最后一列。这些逗号可能是句点,因此您将传递this.rssi1
,但是原样您正在通过this
和rssi1
。