gpt4 book ai didi

Android - AlertDialog 导致 android.view.WindowLeaked

转载 作者:行者123 更新时间:2023-11-30 02:38:30 26 4
gpt4 key购买 nike

我正在尝试运行我自己的另一个应用程序。如果未安装其他应用程序,那么我希望弹出一个对话框,询问您是否要安装它,如果您这样做,它将为您打开市场。但是,我收到此错误。这是什么错误?是什么原因造成的,我该如何解决?

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
barcodeAlive = true;

try {

startActivityForResult(new Intent(
"com.google.zxing.client.android.SCAN").putExtra(
"SCAN_MODE", "QR_CODE_MODE"), 0);
} catch (ActivityNotFoundException anfe) {

new Handler().postDelayed(new Runnable() {

@Override
public void run() {

showDownloadDialog(BarcodeActivity.this,
"QR Reader could not found..",
"Do you want to download QR Reader ? ", "Yes", "No");
}
}, DELAY);
}
}

private static AlertDialog showDownloadDialog(final Activity activity,
CharSequence stringTitle, CharSequence stringMessage,
CharSequence stringButtonYes, CharSequence stringButtonNo) {

final AlertDialog.Builder downloadDialog = new AlertDialog.Builder(
activity);
downloadDialog.setTitle(stringTitle);
downloadDialog.setMessage(stringMessage);
downloadDialog.setPositiveButton(stringButtonYes,
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialogInterface, int i) {

Uri uri = Uri.parse("market://search?q=pname:"
+ PACKAGE);
try {
activity.startActivity(new Intent(
Intent.ACTION_VIEW, uri));
} catch (ActivityNotFoundException anfe) {

} catch (Exception e) {
}
}
});
downloadDialog.setNegativeButton(stringButtonNo,
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialogInterface, int i) {

downloadDialog
.getContext()
.startActivity(
new Intent(downloadDialog.getContext(),
MainActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY));
}
});
downloadDialog.setCancelable(false);
return downloadDialog.show();
}

最佳答案

您应该在开始其他Activity 之前dismiss() 您的对话框。如果让它打开,就会漏窗。

关于Android - AlertDialog 导致 android.view.WindowLeaked,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26143433/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com