ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 새 webview 창에서 스캔 한 링크를 여는 방법 AndroidStudio Zxing
    카테고리 없음 2020. 8. 15. 12:34

    질문

    바코드 스캐너 애플리케이션이 있습니다. 난 할 수 없어 QRcode를 스캔 한 후 (링크가 있음) 새 webview Activity에서 열도록 팝업 Activity에서

    도움을 청해 초보자 안드로이드 스튜디오 자바

    import android.app.Activity;
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.google.zxing.integration.android.IntentIntegrator;
    import com.google.zxing.integration.android.IntentResult;
    
    public class ReaderActivity extends AppCompatActivity {
    private Button scan_btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reader);
        scan_btn = (Button) findViewById(R.id.scan_btn);
        final Activity activity = this;
        scan_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                IntentIntegrator integrator = new IntentIntegrator(activity);
    
     integrator.setDesiredBarcodeFormats(IntentIntegrator.DATA_MATRIX_TYPES);
                integrator.setPrompt("Scan");
                integrator.setCameraId(0);
                integrator.setBeepEnabled(false);
                integrator.setBarcodeImageEnabled(false);
                integrator.initiateScan();
            }
        });
    }
    
     @Override
     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, "You cancelled the scanning", 
      Toast.LENGTH_LONG).show();
            }
            else {
                Toast.makeText(this, 
     result.getContents(),Toast.LENGTH_LONG).show();
    
    
              }
            }
            else {
                super.onActivityResult(requestCode, resultCode, data);
            }
        }
    }

     

    답변1

    링크를 로드해야하는 경우 webView Activity을 생성한 다음 putExtrasgetExras 를 사용하여 스캐너 결과 webView Activity을 전달하십시오. 그런 다음 동일한 Activity에서 webview를 로드하십시오.



     

     

     

     

    출처 : https://stackoverflow.com/questions/58281988/how-to-open-a-scanned-link-in-a-new-webview-window-androidstudio-zxing

    댓글

Designed by Tistory.