Q:

android.view. WindowManager$BadTokenException: - popup window on activity start

I have been hunting for the answer to this but most seem to point to getApplicationContext() issues but I am not using getApplicationContext(). 
Basically I am trying to have a popup window open on start up of a activity but when the activity starts it force closes with the above error.  
The code im have writen is:
protected void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    setContentView(R.layout.installguides_menu);
    setTitleFromActivityLabel(R.id.title_text);

    btn_Back = (Button) findViewById(R.id.btn_Back);
    btn_Back.setOnClickListener (btn_Back_onClick);

    btn_Ubuntu10Guide   = (Button) findViewById(R.id.btn_Ubuntu10Guide);
    btn_Ubuntu12Guide   = (Button) findViewById(R.id.btn_Ubuntu12Guide);
    btn_BacktrackGuide  = (Button) findViewById(R.id.btn_BacktrackGuide);
    btn_DebianGuide     = (Button) findViewById(R.id.btn_DebianGuide);

    btn_Ubuntu10Guide   .setOnClickListener (btn_Ubuntu10Guide_onClick);
    btn_Ubuntu12Guide   .setOnClickListener (btn_Ubuntu12Guide_onClick);
    btn_BacktrackGuide  .setOnClickListener (btn_BacktrackGuide_onClick);
    btn_DebianGuide     .setOnClickListener (btn_DebianGuide_onClick);

    LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  
    View popupView = layoutInflater.inflate(R.layout.donation_popup, null);  
             final PopupWindow popupWindow = new PopupWindow(
               popupView, 
               LayoutParams. WRAP_CONTENT,  
                     LayoutParams. WRAP_CONTENT);  

     Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
     btnDismiss.setOnClickListener(new Button. OnClickListener(){

     public void onClick(View v) {
      popupWindow.dismiss();
     }});

     popupWindow.showAsDropDown(btn_Ubuntu10Guide, 50, -30);
}

Hope you guys can help, been hunting for the answer for hours so your my last hope! 

A:

My first guess is that you are not allowed to show a pop-up inside onCreate.  It is for initializing your application and constructing your layout, but you are forcing it to display a pop-up instead.  
onStart() is a more suitable place to show it.  Override this function and show your pop-up there.  If you prefer to do it in onResume(), note that the user will see it not only when they launch the application but also when they come back to it after navigating away to another activity. 
EDIT 2: Try this for creating the pop-up in onStart or onCreate: 
       LayoutInflater inflater = (LayoutInflater)
               this.getSystemService(Context. LAYOUT_INFLATER_SERVICE);
            PopupWindow pw = new PopupWindow(
               inflater.inflate(findViewById(R.id.popup_layout), null, false), 
               100, 
               100, 
               true);

// delaying popup until after all application initialization is done
    findViewById(R.id.main_page_layout).post(new Runnable() {
       public void run() {
         pw.showAtLocation(findViewById(R.id.main_page_layout), Gravity. CENTER, 0, 0);
       }
    });

Add id's to your activity and pop-up layouts using 
android:id="@+id/main_page_layout"

and 
android:id="@+id/popup_layout"

respectively so that they match the id's you will use in the code above.