こんにちは私はそれがexsitの場合よりも存在しない場合は、HashMapでオブジェクトを保存しようとしています。私は新しいデータでその値を制御したいです。データがsthをやりたいと思っているよりも変化している。 else。しかし、私が新しいデータとハッシュ値を比較しようとするたびに、毎回同じように見えました。どうすればこの問題を処理できますか。コードがあります:HashMapはアンドロイドで安定していません
BluetoothLeDevice deviceLe;
private Map<String, byte[]> mMacMap;
byte [] integer0 =new byte[4];
byte[] tempInteger0=new byte[4];
public void addSensor(String macId, BluetoothLeDevice deviceLe) {
byte [] addSensorrecord=deviceLe.getScanRecord();
int j=0;
for(int i=15;i<19;i++)
{
integer0 [j]=addSensorrecord[i];
j++;
}
if (mMacMap.containsKey(macId)) {
tempInteger0 = mMacMap.get(macId);
if(!integer0 .equals(tempInteger0))
{
mMacMap.remove(macId);
mMacMap.put(macId, integer0);
new SendBLEData().execute(deviceLe);
}
} else {
final byte [] LocalInteger0=new byte[4];
int t=0;
for(int i=15;i<19;i++)
{
LocalInteger0[t]=addSensorrecord[i];
t++;
}
mMacMap.put(macId, LocalInteger0);
new SendBLEData().execute(deviceLe);
}
}
ヒント:Javaコーディングスタイルのガイドを読んでください。変数名はlowerCaseから始まります。また、変数の意図について何かを示す名前を使用する必要があります。だから...一体何についてInteger0配列ですか?あなたはコードを書いているだけで、どこにでも混乱を生み出しています。 – GhostCat
次に、コードを理解するために、使用している変数の宣言を見る必要があります。 – GhostCat
デクリメントが追加されました – mesopotamia