Java 在特定活动中隐藏AlertDialog

Java 在特定活动中隐藏AlertDialog,java,android,mobile,alert,Java,Android,Mobile,Alert,我有一份报价申请。当我打开应用程序的main活动时,如果服务器端有更新的新数据,则会显示一个警报对话框,用于转到设置活动。显示需要一些时间,因此,如果应用程序已处于设置活动,它仍会显示警报对话框,以转到设置活动 我想阻止警报对话框在设置活动中显示,但继续在其他活动中显示。下面是我的AlertDialog代码。我该怎么做 public class UpdatesDialogActivity extends Activity { @Override protected void o

我有一份报价申请。当我打开应用程序的
main活动
时,如果服务器端有更新的新数据,则会显示一个
警报对话框
,用于转到
设置活动
。显示需要一些时间,因此,如果应用程序已处于
设置活动
,它仍会显示
警报对话框
,以转到
设置活动

我想阻止
警报对话框
设置活动
中显示,但继续在其他活动中显示。下面是我的
AlertDialog
代码。我该怎么做

public class UpdatesDialogActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AlertDialog.Builder builder = new AlertDialog.Builder(UpdatesDialogActivity.this);
        builder.setTitle("Download New Status");
        builder.setMessage("There Are New Status Arrived. Push Download Button From Settings.");

        builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                Intent intent = new Intent(UpdatesDialogActivity.this, SettingsActivity.class);
                finish();
                startActivity(intent);
            }

        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                finish();
            }

        });

        builder.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP)
                    finish();
                return false;
            }
        });

        builder.show();
    }

    // ==============================================================================

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();

    }


}

您可以进行“instanceof”检查,查看当前活动是设置还是其他

if(activity instanceof SettingsActivity){
//don;t show dialog
}else{
//show dialog
}

希望这会有所帮助。

嗨!我是初学者,请你澄清更多或可以修改我的代码上面,可以把这里?