Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android的对话框中显示存储在字符串变量中的结果_Android_String_Qr Code_Android Dialog - Fatal编程技术网

如何在android的对话框中显示存储在字符串变量中的结果

如何在android的对话框中显示存储在字符串变量中的结果,android,string,qr-code,android-dialog,Android,String,Qr Code,Android Dialog,我正在尝试使用xzing import扫描二维码,并用两个按钮在对话框中显示二维码详细信息。第一个按钮应该能够拨打固定号码(紧急号码),第二个按钮应该能够通过whatsapp共享二维码详细信息以及我的当前位置 public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) {

我正在尝试使用xzing import扫描二维码,并用两个按钮在对话框中显示二维码详细信息。第一个按钮应该能够拨打固定号码(紧急号码),第二个按钮应该能够通过whatsapp共享二维码详细信息以及我的当前位置

       public void onActivityResult(int requestCode, int resultCode, Intent intent) {
                if (requestCode == 0) {
                    if (resultCode == RESULT_OK) {
get the extras that are returned from the intent
                        String contents = intent.getStringExtra("SCAN_RESULT");


                        String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
    >I want to show the string value in the dialogbox with 2 buttons.                    
                        showDialog(this);

                    }
                }
            }

            private void showDialog(AndroidQrCodeExample androidQrCodeExample) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this)
 >I dont know whether I can use this command setmessage to   display as I am new in android.Please explain me How to do it.                     
.setMessage(contents)
                        .setTitle("Response")
                        .setPositiveButton("OK",new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog,int which) {
                                dialog.dismiss();
                            }

                        });

                builder.show();
            }
        }strong text

您现有的警报代码有什么问题?qr代码的输出结果存储在名为contents的字符串变量中,我正在尝试将此值传递给showdialog方法,但我没有获得输出,但当我尝试在onActivityResult函数中写入showdialog方法时,我得到了结果。您能帮我将值从一个方法传递到另一个方法吗?那么您正试图通过onActivityResult将字符串传递回被调用的活动?不完全是这样。我正试图将字符串从onActivityResult传递到showdialog,以便内容中存储的信息应该在对话框中。因此,您将字符串传递到onActivityResult中对吗?现在你只需要显示对话框?