Possible Duplicate:
Android 1.6: "android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an application"안드로이드에 윈도우 오류를 추가 할 수 없습니다
내가 다른 일을 시도했습니다,하지만 난 여전히 같은 오류 계속 :이 줄에
android.view.WindowManager$BadTokenException: Unable to add window
을 :
alertDialog.show() ;
코드를 살펴볼 수 있습니까?
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
Context mContext = this;
alertDialog = new AlertDialog.Builder(mContext).create();
LoadData();
}
public void LoadData()
{
Thread t1 = new Thread(this);
t1.start();
}
private Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
if(!rssItems.isEmpty())
{
switch (msg.what) {
case STOPSPLASH:
//remove SplashScreen from view
//splash.setVisibility(View.GONE);
Intent intent = new Intent(
"news.displayNews");
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
NewsDisplayer.rssItems.clear();
NewsDisplayer.rssItems.addAll(rssItems);
startActivity(intent);
Close();
break;
}
}
else
{
alertDialog.setCancelable(false); // This blocks the 'BACK' button
alertDialog.setMessage("No connection.");
alertDialog.setTitle("Error...");
alertDialog.setButton("Again", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
LoadData();
}
});
alertDialog.setButton2("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
System.exit(0);
}
});
alertDialog.show();
}
}
};
이 질문은 어떤 방향을 제시합니까? http://stackoverflow.com/questions/2634991/android-1-6-android-view-windowmanagerbadtokenexception-unable-to-add-window? – Sampson