Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.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 - Fatal编程技术网

Android 调用意图时出错

Android 调用意图时出错,android,Android,调用intentstartActivity(新intent(this,Advogado1.class))时出错,如何正确调用此intent AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Atenção"); alert.setMessage("Digite o Numero da OAB");

调用intent
startActivity(新intent(this,Advogado1.class))时出错
,如何正确调用此
intent

            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.setTitle("Atenção");
            alert.setMessage("Digite o Numero da OAB");

            // Set an EditText view to get user input
            final EditText input = new EditText(this);
            alert.setView(input);

            alert.setPositiveButton("Ok",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {

                            int oab = Integer.parseInt(input.getText()
                                    .toString());
                            // Do something with value!

                            if (oab == 1) {

                                startActivity(new Intent(this, Advogado1.class));
                            }

                        }
                    });

            alert.setNegativeButton("Cancelar",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {
                            // Canceled.
                        }
                    });

            alert.show();
呼吁,

startActivity(new Intent(this, Advogado1.class));
不应该使用“this”,它应该使用

startActivity(new Intent(NameOfYourActivity.this, Advogado1.class)); 

因为
引用了扩展
DialogInterface.OnClickListener
的匿名类,而不是您的
活动
类。意图需要调用方类作为活动的实例。

请发布您的logcat输出