QR码 - 怎么样?

时间:2018-06-02 16:25:47

标签: android split qr-code

我想隐藏QR码的结果...... 例如:?re = 123456789012& rr = 我只想显示123456789012并隐藏?re =和& rr 我在阅读和人们说使用Split方法,它是正确的吗?

protected void  onActivityResult(int requestCode,int resultCode,Intent data){
     IntentResult result = IntentIntegrator.parseActivityResult(requestCode,resultCode,data);
     if(result != null){
         if(result.getContents()==null){
             Toast.makeText(this,"cancelled", Toast.LENGTH_LONG).show();
         }
        else{
             resultado.setText(result.getContents());
         }
     }
     else {
         super.onActivityResult(requestCode,resultCode,data);
      }
     }

1 个答案:

答案 0 :(得分:0)

尝试使用子字符串函数: -

<强> function : -

private String getQR(String content)
{
 return content.substring(4,15);    
}

<强> function implementation : -

     if(result.getContents()==null){
         Toast.makeText(this,"cancelled", Toast.LENGTH_LONG).show();
     }
    else{
         resultado.setText(getQR(result.getContents())); // <- <-
     }