json オブジェクトから返されたタグに、enum クラス内の値のいずれかが含まれているかどうかを確認したかったのです。
Gson gson = new Gson();
AnalysisResult result = gson.fromJson(data, AnalysisResult.class);
for(Enum p : Enum.values()){
if(p.name().equals(result.tags)){
Intent in1 = new Intent(Analyze.this, Analyze2.class);
startActivity(in1);
}else {
for (final Caption caption : result.description.captions) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
speakOut("Result:" + caption.text);
}
}, 100);
}
}
}
ここに私の列挙型クラスがあります
public enum Enum {
person,
people,
people_baby,
people_crowd,
people_group,
people_hand,
people_many,
people_portrait,
people_show,
people_tattoo,
people_young
}
これは返されたタグです...
"tags":["テディ","屋内","衣服","ネクタイ","人物","クマ","着ている","緑","茶色","ぬいぐるみ","座っている"," man","bow","neck","face","shirt","blue","hat","close","grey","laying","black","glasses","head" ,"ベッド","白","抱っこ","猫","寝ている"]}
私の問題は、それが常にelseステートメントに移動することです。コードのどこが間違っていると思いますか?