java的if语句的作用_我的java if语句似乎不起作用

我不知道为什么但是当我在我的

Android应用程序中使用zxing来获取条形码时,格式返回为EAN_13但是我的if staement决定它不是,然后在我的Toast通知中显示EAN_13.关于它为什么破碎的任何线索?

public void onActivityResult(int requestCode, int resultCode, Intent intent) {

IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

if (scanResult != null) {

if (resultCode == 0){

//If the user cancels the scan

Toast.makeText(getApplicationContext(),"You cancelled the scan", 3).show();

}

else{

String contents = intent.getStringExtra("SCAN_RESULT");

String format = intent.getStringExtra("SCAN_RESULT_FORMAT").toString();

if (format == "EAN_13"){

//If the barcode scanned is of the correct type then pass the barcode into the search method to get the product details

Toast.makeText(getApplicationContext(),"You scanned " + contents, 3).show();

}

else{

//If the barcode is not of the correct type then display a notification

Toast.makeText(getApplicationContext(),contents+" "+format, 3).show();

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值