我有问题。我已经制作了一个二维码扫描仪,当他扫描代码时,他把结果像烤面包一样,但我希望它作为警报消息。有人可以帮忙吗?
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class MainActivity extends AppCompatActivity implements
ZXingScannerView.ResultHandler{
private ZXingScannerView zXingScannerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void scan(View view){
zXingScannerView =new ZXingScannerView(getApplicationContext());
setContentView(zXingScannerView);
zXingScannerView.setResultHandler(this);
zXingScannerView.startCamera();
}
@Override
protected void onPause() {
super.onPause();
zXingScannerView.stopCamera();
}
@Override
public void handleResult(Result result) {
Toast.makeText(getApplicationContext(),result.getText(),Toast.LENGTH_SHORT).show();
zXingScannerView.resumeCameraPreview(this);
}
}
这是代码中的最后4行。