Как добиться чего-то вроде «финиша» в неактивном классе в android?

Это диалоговое окно спрашивает, хотите ли вы установить какое-либо другое приложение... поэтому при нажатии кнопки onclicked он должен вернуться на предыдущий экран

    downloadDialog.setNegativeButton(stringButtonNo,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                         finish();
                }
            });

, это выдает ошибку:

Метод finish() не определен для нового типа DialogInterface.OnClickListener(){}

как я могу достичь того, что я хотел???

package com.Android.barcode;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class BarcodeActivity extends Activity {
    public static String upc;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        IntentIntegrator.initiateScan(this);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
        case IntentIntegrator.REQUEST_CODE: {
            if (resultCode != RESULT_CANCELED) {
                IntentResult scanResult = IntentIntegrator.parseActivityResult(
                        requestCode, resultCode, data);
                if (scanResult != null) {
                    upc = scanResult.getContents();

                    Intent intent = new Intent(BarcodeActivity.this, BarcodeResult.class);
                    startActivity(intent);
                    // put whatever you want to do with the code here
/*                  TextView tv = new TextView(this);
                    tv.setText(upc);
                    setContentView(tv);*/
                }
            }
            break;
        }
        }
    }
}
5
задан Housefly 19 May 2012 в 05:20
поделиться