Android:异步任务执行doInBackground()时发生错误

Gsu*_*rha 2 java android json android-asynctask

在使用异步任务之前,我的代码是可行的.所以我在我的代码中做了一些更改,现在进度条显示但是得到以下错误.

原木猫:

08-07 06:43:15.875: E/AndroidRuntime(1734): FATAL EXCEPTION: AsyncTask #1
08-07 06:43:15.875: E/AndroidRuntime(1734): java.lang.RuntimeException: An error occured while executing doInBackground()
08-07 06:43:15.875: E/AndroidRuntime(1734):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
08-07 06:43:15.875: E/AndroidRuntime(1734):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-07 06:43:15.875: E/AndroidRuntime(1734):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-07 06:43:15.875: E/AndroidRuntime(1734):     ... 18 more
Run Code Online (Sandbox Code Playgroud)

mycode的:

        protected String doInBackground(String... args) {
            final EditText eKey = (EditText) findViewById(R.id.edtxt_key);
            inputs = eKey.getText().toString();
            if (inputs.matches("")) {

            } else {
                keys = url + inputs;
                JSONParser jParser = new JSONParser();
                JSONObject json = jParser.getJSONFromUrl(keys);
                try {
                    satu = json.getJSONObject(TAG_1);
                    String two = satu.getString(TAG_2);
                    String three = satu.getString(TAG_3);
                    if (two.matches("") | three.matches("")) {
                        AlertDialog.Builder builder = new AertDialog.Builder(MainActivity.this);
                        builder.setMessage("not found!").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                 eKey.setText("");
                                 status.setText("Key not found!");
                            }
                        });
                        AlertDialog alert = builder.create();
                        alert.show();
                    } else {
                        Intent x = new Intent(MainActivity.this, result.class);
                        x.putExtra("bac", two);
                        x.putExtra("cab", three);
                        startActivity(x);
                        eKey.setText("");
                        keys = "";
                        inputs = "";
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            return null;
        }
Run Code Online (Sandbox Code Playgroud)

出了什么问题?提前致谢.

zkm*_*sck 7

alert.show();
Run Code Online (Sandbox Code Playgroud)

eKey.setText("");
Run Code Online (Sandbox Code Playgroud)

无法在后台任务中执行.传递一个返回值

doInBackground()

onPostExecute()

方法并在那里执行UI任务.