title: parsing gives error in asyn-task in android
body: <p>Please following code I am not getting why it's not loading data. below activity is started after splash activity &amp; here I am trying to download data from server &amp; parse it &amp; try to attach it to spinner but it force close the application saying element not found at line 1 so I am not getting why it's not working...</p>
  
  <p>Edited:--- Code is working on android 2.3 &amp; above but not on android 2.2  minimum sdk version required is 8 (Android 2.2) </p>
  
  <pre><code>public class Registration extends Activity{
  
  private List&lt;RegisterMessage&gt; regis_msg;
  private List&lt;CountryMessage&gt; country_msg;
  ArrayList&lt;String&gt; countryName,countryCode,isoCode,countryFlag;
  EditText fname,sname,email,mobileno;
  Spinner country;
  AppPreferences ap;
  Button btnregister;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.registration);
  
      country = (Spinner)findViewById(R.id.country);
      fname = (EditText)findViewById(R.id.fname);
      sname  = (EditText)findViewById(R.id.sname);
      email = (EditText)findViewById(R.id.email);
      mobileno = (EditText)findViewById(R.id.mobileno);
  
      ap = new AppPreferences(getApplicationContext());
  
  //  mobileno.setText(ap.getPreferences("MobileNo"));
  
      btnregister = (Button)findViewById(R.id.btnregister);
  
      btnregister.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  if(fname.getText().toString().equals("")){
                      Toast.makeText(getApplicationContext(), "Please Enter Firstname.", Toast.LENGTH_SHORT).show();
                      fname.setFocusable(true);
                      fname.requestFocus();
                  }else if (sname.getText().toString().equals("")){
                      Toast.makeText(getApplicationContext(), "Please Enter Surname.", Toast.LENGTH_SHORT).show();
                      sname.setFocusable(true);
                      sname.requestFocus();
                  }else if (email.getText().toString().equals("")){
                      Toast.makeText(getApplicationContext(), "Please Enter Email address.", Toast.LENGTH_SHORT).show();
                      email.setFocusable(true);
                      email.requestFocus();
                  }else if (mobileno.getText().toString().equals("")){
                      Toast.makeText(getApplicationContext(), "Please Enter Mobile No.", Toast.LENGTH_SHORT).show();
                      email.setFocusable(true);
                      email.requestFocus();
                  }else{
                      new RegistrationTry().execute();
                  }
              }
        });
  
      if(!isOnline()) {
          Log.v("isOnline",isOnline()+"");
          Toast.makeText(getApplicationContext(), "You device is not connected to the internet.",Toast.LENGTH_LONG).show();
      }else{
          new CountryData().execute();
      }
  
  }
  
  public boolean isOnline(){
      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo netInfo = cm.getActiveNetworkInfo();
      boolean isconnected;
      if (netInfo==null || !netInfo.isConnected())
      isconnected=false;
      else
      isconnected=true;
      Log.v("isOnliNe",isconnected+"");
      return isconnected;
  }   
  
  class CountryData extends AsyncTask&lt;Object, Object, Object&gt; {
     // private CustomizeDialog Dialog = new CustomizeDialog(Registration.this);
      private ProgressDialog Dialog = new ProgressDialog(Registration.this);
      @Override
      protected void onPreExecute() {
          Dialog.setMessage("Loading please wait........");
          Dialog.show();
      }
  
      protected Void doInBackground(Object...params) {
          try{
              String url= newsReaderUrls.BASE_URL + newsReaderUrls.COUNTRY_URL;
              Log.v("URL",url);
              BaseFeedParser parser  =  new BaseFeedParser(url);
              country_msg = parser.CountryParse();
              countryName = new ArrayList&lt;String&gt;();
              countryCode = new ArrayList&lt;String&gt;();
              isoCode = new ArrayList&lt;String&gt;();
              countryFlag = new ArrayList&lt;String&gt;();
              countryName.add(0, "Select");
              for (CountryMessage msg : country_msg){
                   countryName.add(msg.getCountryName());
                   countryCode.add(msg.getCountryCode());
                   isoCode.add(msg.getIsoCode());
                   countryFlag.add(msg.getCountryFlag());
              }
          } catch (Throwable t){
              Log.e("AndroidNews",t.getMessage(),t);
          }
          return null;
      }
  
       protected void onProgressUpdate(Object... values){
          // TODO Auto-generated method stub
          super.onProgressUpdate(values);
       }
  
      @Override
      protected void onPostExecute(Object result) {
          if(Dialog.isShowing()){
              Dialog.dismiss();
          }
          String[] array_spinner = countryName.toArray(new String[countryName.size()]);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt; (getApplicationContext(),android.R.layout.simple_spinner_item,array_spinner);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          country.setAdapter(adapter);
          String cn = ap.getPreferences("CountryIso");
          if(!cn.equals("")){
              int index = isoCode.indexOf(cn);
              country.setSelection(index+1);
          }else if(countryName.indexOf("Nigeria") !=  -1){
              country.setSelection(countryName.indexOf("Nigeria")+1);
          }
      }
  }
  
  class RegistrationTry extends AsyncTask&lt;Void, Void, Void&gt; {
     // private CustomizeDialog Dialog = new CustomizeDialog(Registration.this);
      private ProgressDialog Dialog = new ProgressDialog(Registration.this);
      int foreward;
      @Override
      protected void onPreExecute() {
          Dialog.setMessage("Loading please wait........");
          Dialog.show();
      }
  
      protected void onProgressUpdate(Void... unused) {
      }
  
  
      protected Void doInBackground(Void...params) {
          try{
              String defaultC_code="ng";
              /*if(countryName.size()&lt;0){
                  defaultC_code = "ng";
              }else{
                  int index = country.getSelectedItemPosition();
                  defaultC_code = isoCode.get(index-1);
              }*/
              ap.savePreferences("MobileNo", mobileno.getText().toString());
              String url= newsReaderUrls.BASE_URL + newsReaderUrls.REGISTER_URL + "Mobile="+ mobileno.getText().toString()+
                          "&amp;First_Name="+fname.getText().toString()+"&amp;Last_Name="+sname.getText().toString()+
                          "&amp;Email="+email.getText().toString()+"&amp;Device_Type=Phone&amp;Device_Platform=Android"+
                          "&amp;ISO_Code=" + defaultC_code;
              Log.v("Login", url);
              BaseFeedParser parser = new BaseFeedParser(url);
              regis_msg = parser.RegisterParse();
  
              for (RegisterMessage msg : regis_msg){
                  Log.v("Status", msg.getStatus());
                  foreward = Integer.parseInt(msg.getStatus());
              }
  
          } catch (Throwable t){
              Log.e("AndroidNews",t.getMessage(),t);
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          if(foreward == 2 || foreward == 3){
              ap.savePreferences("Registered", "yes");
              Intent i = new Intent(Registration.this,DashBoard.class);
              startActivity(i);
              finish();
          }else{
              Toast.makeText(getBaseContext(), "Registration failed please try later.", Toast.LENGTH_SHORT).show();
          }
          if(Dialog.isShowing()){
              Dialog.dismiss();
          }
      }
  }
  </code></pre>
  
  <p>}   </p>
  
  <p>LogCat </p>
  
  <pre><code>10-31 16:13:41.022: ERROR/AndroidNews(599): org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found
  10-31 16:13:41.022: ERROR/AndroidNews(599): java.lang.RuntimeException: org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at com.websoft.android.parser.BaseFeedParser.CountryParse(BaseFeedParser.java:189)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at com.websoft.android.newsreel.Registration$CountryData.doInBackground(Registration.java:117)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at com.websoft.android.newsreel.Registration$CountryData.doInBackground(Registration.java:1)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at java.lang.Thread.run(Thread.java:1096)
  10-31 16:13:41.022: ERROR/AndroidNews(599): Caused by: org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at org.apache.harmony.xml.ExpatParser.finish(ExpatParser.java:553)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:483)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:320)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:277)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at android.util.Xml.parse(Xml.java:87)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     at com.websoft.android.parser.BaseFeedParser.CountryParse(BaseFeedParser.java:187)
  10-31 16:13:41.022: ERROR/AndroidNews(599):     ... 8 more
  10-31 16:13:41.022: DEBUG/AndroidRuntime(599): Shutting down VM
  10-31 16:13:41.042: WARN/dalvikvm(599): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599): FATAL EXCEPTION: main
  10-31 16:13:41.042: ERROR/AndroidRuntime(599): java.lang.NullPointerException
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at com.websoft.android.newsreel.Registration$CountryData.onPostExecute(Registration.java:140)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.os.AsyncTask.finish(AsyncTask.java:417)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.os.Looper.loop(Looper.java:123)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at java.lang.reflect.Method.invoke(Method.java:521)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  10-31 16:13:41.042: ERROR/AndroidRuntime(599):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>