title: get extra data android, keep force close apps
body: <p>here is how i sent extra data</p>
  
  <pre><code>btn_category.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      WriteLog.d("ThangTB", "onclick image");
                      Intent i=new Intent(MainActivity.this,QuoteList.class);
                      i.putExtra("category", "ok");
                      MainActivity.this.startActivity(i);
                  }
              });
  </code></pre>
  
  <p>and receive data using</p>
  
  <pre><code>Intent intent = getIntent();
  
      //ambil data putextra variabel category dari intent     
      String category = intent.getStringExtra("category");
      //if category sama dengan ok
      if(category=="ok")
          spinnerCategory.performClick();
  </code></pre>
  
  <p>it's keep force close when click the button.
  i've try <a href="https://stackoverflow.com/questions/5265913/how-to-use-putextra-and-getextra-for-string-data">How to use putExtra() and getExtra() for string data</a>, but still force close when i click the button</p>
  
  <p>here is complete code of QuoteList</p>
  
  <pre><code>/**
  </code></pre>
  
  <p>* 
   */
  public class QuoteList extends AbstractContentActivity {</p>
  
  <pre><code>Spinner spinnerPage;
  Spinner spinnerCategory;
  ListView lv;
  
  ImageButton btn_expand;
  ImageButton btn_logo;
  Button btn_next;
  Button btn_pre;
  
  TextView tv_empty;
  QuoteAdapter adapter;
  DataHeper dataHeper;
  ArrayList&lt;Quote&gt; listData;
  private ProgressDialog dialogLoading;
  
  private boolean isSort = false;
  private int iStart =0;
  int total;
  ArrayList&lt;String&gt; listSpinerPage;
  ArrayList&lt;String&gt; listSpinerCategory;
  
  private int currentPostion =0;
  private boolean hasGetTotal = false;
  private boolean firstStart = true; 
  /* (non-Javadoc)
   * @see com.android.jokesapp.jokes2.activity.AbstractActivity#getViewLayoutId()
   */
  @Override
  protected int getViewLayoutId() {
      // TODO Auto-generated method stub
      return R.layout.full_quotes_index;
  }
  
  /* (non-Javadoc)
   * @see com.android.jokesapp.jokes2.activity.AbstractContentActivity#initView()
   */
  @Override
  protected void initView() {
      // TODO Auto-generated method stub
      super.initView();
      spinnerPage = (Spinner)findViewById(R.id.fqi_page_no);
      spinnerCategory = (Spinner)findViewById(R.id.fqi_category);
      lv = (ListView)findViewById(R.id.fqi_ListView);
      btn_expand = (ImageButton)findViewById(R.id.fqi_expand_quotes_btn);
      btn_logo = (ImageButton)findViewById(R.id.actionbar_logo_btn);
      btn_next = (Button)findViewById(R.id.fqi_next_btn);
      btn_pre = (Button)findViewById(R.id.fqi_previous_btn);
  
      tv_empty = (TextView)findViewById(R.id.empty);
  
      SplashActivity.displayBanner(this);
  
      dataHeper = new DataHeper(getApplicationContext());
      listData = new ArrayList&lt;Quote&gt;();
      listSpinerPage = new ArrayList&lt;String&gt;();
      listSpinerCategory = new ArrayList&lt;String&gt;();
  
  
      Intent intent = getIntent();
  
      //ambil data putextra variabel category dari intent     
      String category = intent.getStringExtra("category");
      //if category sama dengan ok
      if(category=="ok")
          spinnerCategory.performClick();
  
      //spinnercategory performclick
  
  
  
  
  
  
      btn_expand.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if (adapter.isExpand()) {
                  adapter.setExpand(false);
                  adapter.notifyDataSetChanged();
                  btn_expand.setImageResource(R.drawable.actionbar_ic_resize);
                  btn_expand.setAdjustViewBounds(true);
              }else{
                  adapter.setExpand(true);
                  adapter.notifyDataSetChanged();
                  btn_expand.setImageResource(R.drawable.actionbar_ic_resize_pressed);
                  btn_expand.setAdjustViewBounds(true);
              }
          }
      });
  
      lv.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int pos,
                  long id) {
              // TODO Auto-generated method stub
              Intent i = new Intent(getApplicationContext(), QuoteView.class);
              i.putExtra(Constants.Bundle_quote, listData.get(pos));
              currentPostion = pos;
              startActivity(i);
          }
      });
  
      btn_logo.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent i = new Intent(getApplicationContext(), MainActivity.class);
              startActivity(i);
              QuoteList.this.finish();
          }
      });
  
  }
  
  /* (non-Javadoc)
   * @see com.android.jokesapp.jokes2.activity.AbstractActivity#onResume()
   */
  @Override
  protected void onResume() {
      new GetData().execute();
      super.onResume();
  }
  /**
   * get data task
   * @author ThangTB
   *
   */
  private class GetData extends AsyncTask&lt;Object, Object, Object&gt;{
  
      public GetData() {
      }
      /* (non-Javadoc)
       * @see android.os.AsyncTask#onPreExecute()
       */
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          dialogLoading = DialogLoading.Loading(activity,"Loading jokes...");
          dialogLoading.show();
      }
      /* (non-Javadoc)
       * @see android.os.AsyncTask#doInBackground(Params[])
       */
      @Override
      protected Object doInBackground(Object... params) {
          // TODO Auto-generated method stub
          if (!hasGetTotal) {
              total = dataHeper.getTotalQuotesNoFilter();
              if (total&gt;0) {
                  if (total&gt;=50) {
                      for (int i = 1; i &lt;= total-50; i+=50) {
                          String s = (i)+" - "+ (i+49);
                          listSpinerPage.add(s);
                      }
  
                      String s1 = listSpinerPage.get(listSpinerPage.size()-1);
                      String s2 = s1.substring(s1.indexOf("-")+1); 
                      int num =Integer.parseInt(s2.trim());
                      if ( num&lt;total) {
                          listSpinerPage.add((num)+" - "+ total);
                      }
                  }else{
                      listSpinerPage.add(1+" - "+ total);
                  }
  
              }
              hasGetTotal = true;
          }
  
          return null;
      }
  
      /* (non-Javadoc)
       * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
       */
      @Override
      protected void onPostExecute(Object result) {
          if (total&gt;0) {
              new GetQuoteData(iStart, null,"").execute();
              if (firstStart) {
                  tv_empty.setVisibility(View.GONE);
                  //list
                  CustomArrayAdapter spinnerAdapter = new CustomArrayAdapter(getApplicationContext(), 
                          R.layout.spinner_item_style, 
                          listSpinerPage);
                  spinnerPage.setAdapter(spinnerAdapter);
                  spinnerPage.setOnItemSelectedListener(onItemSelectedListener);
                  //category
                  listSpinerCategory = dataHeper.getCategory();
                  CustomArrayAdapter catAdapter = new CustomArrayAdapter(getApplicationContext(),
                          R.layout.spinner_item_style,
                          listSpinerCategory);
                  spinnerCategory.setAdapter(catAdapter);
                  spinnerCategory.setOnItemSelectedListener(selectCategory);
              }
  
          }else{
              tv_empty.setVisibility(View.VISIBLE);
              dialogLoading.dismiss();
          }
  
          firstStart = false;
          super.onPostExecute(result);
      }
  }
  
  OnItemSelectedListener selectCategory =new OnItemSelectedListener() {
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int pos,
              long id) {
          // TODO Auto-generated method stub
          String category = listSpinerCategory.get(pos);
          String sStart = listSpinerPage.get(pos);
          iStart = Integer.parseInt(sStart.substring(0, sStart.indexOf("-")-1).trim());
          new GetQuoteData(iStart, null, category).execute();
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
      }
  };
  
  
  OnItemSelectedListener onItemSelectedListener =new OnItemSelectedListener() {
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int pos,
              long id) {
          // TODO Auto-generated method stub
          String sStart = listSpinerPage.get(pos);
          iStart = Integer.parseInt(sStart.substring(0, sStart.indexOf("-")-1).trim());
          new GetQuoteData(iStart, null, "").execute();
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
      }
  };
  
  OnItemSelectedListener onSpinnerSortItemSelectedListener =new OnItemSelectedListener() {
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int pos,
              long id) {
          // TODO Auto-generated method stub
          String sStart;
          if (!isSort) {
              isSort =true;
              return;
          }else{
              sStart = listSpinerPage.get(spinnerPage.getSelectedItemPosition());
              iStart = Integer.parseInt(sStart.substring(0, sStart.indexOf("-")-1).trim());
              new GetQuoteData(iStart, null, "").execute();
          }
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
  
      }
  };
  
  /**
   * get data task
   * @author ThangTB
   *
   */
  private class GetQuoteData extends AsyncTask&lt;Object, Object, Object&gt;{
      private int start;
      private String sort;
      private String category = "";
      public GetQuoteData(int start, String sort, String category) {
          this.start = start;
          this.sort = sort;
          this.category = category;
      }
      /* (non-Javadoc)
       * @see android.os.AsyncTask#onPreExecute()
       */
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          if (null == dialogLoading) {
              dialogLoading = DialogLoading.Loading(activity,"Loading jokes...");
              dialogLoading.show();
          }else if (!dialogLoading.isShowing()) {
              dialogLoading = DialogLoading.Loading(activity,"Loading jokes...");
              dialogLoading.show();
          }
  
      }
      /* (non-Javadoc)
       * @see android.os.AsyncTask#doInBackground(Params[])
       */
      @Override
      protected Object doInBackground(Object... params) {
          // TODO Auto-generated method stub
          if (category.isEmpty()) listData = dataHeper.getQuoteByLimit(start, 50, sort);
          else listData = dataHeper.getQuoteByCategory(category);
          return null;
      }
  
      /* (non-Javadoc)
       * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
       */
      @Override
      protected void onPostExecute(Object result) {
  
          adapter = new QuoteAdapter(getApplicationContext(), listData);
          adapter.setOnClickCheckBoxListener(new OnClickCheckBoxListener() {
  
              @Override
              public void OnClick(View v, Quote item, int pos) {
                  // TODO Auto-generated method stub
                  WriteLog.d(QuoteList.this.getLocalClassName(), "click");
                  if (item.getIs_favourist()==0) {
                      dataHeper.AddFavourites(String.valueOf(item.getId()));
                      listData.get(pos).setIs_favourist(1);
                  }else{
                      dataHeper.DeleteFavourites(String.valueOf(item.getId()));
                      listData.get(pos).setIs_favourist(0);
                  }
  
                  adapter.setData(listData);
                  adapter.notifyDataSetChanged();
  
              }
          });
          if (listData.size()==0) {
              tv_empty.setVisibility(View.VISIBLE);
          }else{
              tv_empty.setVisibility(View.GONE);
          }
          lv.setAdapter(adapter);
          lv.setSelection(currentPostion);
          currentPostion =0;
          if (dialogLoading.isShowing()) {
              dialogLoading.dismiss();
          }
  
          super.onPostExecute(result);
      }
  }
  </code></pre>
  
  <p>}</p>