我有一个Activity
(ActivityA
),用户可以点击列表中的一个项目,它会打开下一个Activity
(ActivityB
):
public class ActivityA : ReactiveAppCompatActivity<LoginViewModel>
{
ListView AvailableProjectListView;
AvailableProjectAdapter ProjectAdapter;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.AvailableProjects);
AvailableProjectListView.Events().ItemClick
.Subscribe(result => StartDownloadActivity(result.Position));
}
void StartDownloadActivity(int selectedProject)
{
//do some things here before open the next activity
Intent downloadIntent = new Intent(this, typeof(ActivityB));
StartActivity(downloadIntent);
}
}
在下一个Activity
(ActivityB
)中,如果下载过程出错,我会显示AlertDialog
:
this.WhenAnyValue(x => x.ViewModel.DownloadStatusCode)
.Where(x => x == APIRequestResult.UnknownError)
.Subscribe(result =>
{
this.ViewModel.UserAction = LoginUserAction.None;
ShowUnknownErrorAlert();
});
void ShowUnknownErrorAlert()
{
this.ViewModel.DownloadStatusCode = APIRequestResult.None;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle(Resource.String.download_error);
builder.SetMessage(Resource.String.please_try_again_later);
builder.SetNegativeButton(Resource.String.ok, (senderAlert, args) => {
var alert = senderAlert as AlertDialog;
if (alert != null && alert.IsShowing)
{
alert.Dismiss();
}
Finish();
});
AlertDialog dialog = builder.Create();
dialog.Show();
}
AlertDialog
第一次正常运作。但是,在我从ActivityB
再次打开ActivityA
后,警报对话框未显示,并且显示以下消息:
[Dialog] show mWindowManager.addView RuntimeException
可能有什么问题?