title: Click on spinner gives WindowManager$BadTokenException
body: <p>I am using Tabwidget, Tab are implemented in same way which shows in <a href="http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html" rel="nofollow noreferrer">tutorial</a></p>
  <p>&quot;MainActivity -&gt; Activity1 -&gt; Activity2(given Image)&quot;</p>
  <p><img src="https://i.stack.imgur.com/oGyxz.png" alt="view for the current activity" /></p>
  <p>Now clicking on the spinner gives</p>
  <pre><code> android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44eb8748 is not valid; is your activity running?
  </code></pre>
  <p>I have tried <a href="https://stackoverflow.com/questions/7609519/android-spinner-error-android-view-windowmanagerbadtokenexception-unable-to">Android Spinner Error : android.view.WindowManager$BadTokenException: Unable to add window</a> already but that doesn't help me</p>
  <p>I know There is <strong>something wrong with context</strong> but I can't figure out what</p>
  <p>Hear is my Intent which starts <code>DetailActivity</code></p>
  <pre><code>intent = new Intent(getParent(), DetailActivity.class);
  TabGroupActivity parentActivity = (TabGroupActivity)getParent();
  parentActivity.startChildActivity(&quot;SelectActivity&quot;, intent);
  </code></pre>
  <p>My code for the <code>DetailActivity</code> given bellow</p>
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.package_detail);
          setUpViews();
  
          id = getIntent().getExtras().getInt(&quot;WEBSITE_ID&quot;);
  
          adapter = new KeywordAdapter(getApplicationContext(), id,
                  getLNApplication().getKeyworddetail());
          listTags.setAdapter(adapter);
  
          spinneAdapter = new SpinnerListAdapter();
          spinnerList.setAdapter(spinneAdapter);
          spinnerList.setSelection(id, true);
          spinnerList
                  .setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                      public void onItemSelected(AdapterView&lt;?&gt; parent,
                              View view, int position, long id) {
  
                          // txtHeader.setText(getLNApplication().getWebsiteList()
                          // .get(position).getName());
                          adapter.forceReload();
                          adapter = new KeywordAdapter(DetailActivity.this,
                                  position, getLNApplication().getKeyworddetail());
                          listTags.setAdapter(adapter);
                      }
  
                      public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
                      }
                  });
  
      }
  </code></pre>
  <p>code for <code>SpinnerAdapter</code></p>
  <pre><code>public class SpinnerListAdapter extends BaseAdapter {
  
          private List&lt;ClientDetail&gt; siteList;
  
          public SpinnerListAdapter() {
              siteList = getLNApplication().getWebsiteList();
          }
          
          public void forceReload() {
              notifyDataSetChanged();
              
          }
  
          @Override
          public int getCount() {
              return siteList.size();
          }
  
          @Override
          public Object getItem(int position) {
              // TODO Auto-generated method stub
              return siteList.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              View view = convertView;
              
  //          LayoutInflater inflater = (LayoutInflater) context
  //              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      
  //          LayoutInflater inflater = getLayoutInflater();
      
  //          LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
      
              LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
                  view = inflater.inflate(R.layout.spinner_item_display, null);
                  TextView websiteName = (TextView) view.findViewById(R.id.spinnerItem);
              if (siteList.get(position).getName() != null) {
                  websiteName.setText(siteList.get(position).getName());
                  websiteName.setTextColor(0xFF000000);
              }
              return view;
          }
  
          @Override
          public View getDropDownView(int position, View convertView, ViewGroup parent) {
              View view = convertView;
              
  //          LayoutInflater inflater = (LayoutInflater) context
  //                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              
  //          LayoutInflater inflater = getLayoutInflater();
              
  //          LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
              
              LayoutInflater inflater = LayoutInflater.from(DetailActivity.this.getParent());
                  view = inflater.inflate(R.layout.spinner_dropdown_display, null);
                  TextView websiteName = (TextView) view.findViewById(R.id.spinnerDropDownItem);
              if (siteList.get(position).getName() != null) {
                  websiteName.setText(siteList.get(position).getName());
                  websiteName.setTextColor(0xFF000000);
              }
              return view;
          }
      }
  </code></pre>
  <p>Am i doing anything wrong?</p>
  <p>please help me with... Thank you so much</p>