Saturday 31 March 2018

android - How to create a alert message instead of toast

I have a problem. I have made an QR code scanner and i when he scan the code he put the result like toast but I want it as Alert Message. Can anyone help?



    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);

}
}


It is the last 4 lines in code.

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...