title: ResourcesNotFoundException: String resource ID #0x0 (No Response: UI Thread)
body: <p>I am using <code>OkHttpClient</code> to get the Staff List (in <code>JSON</code> form) as response using <code>AsyncTask</code> Function. After getting the response in <code>AsyncTask</code> funtion, while inserting staff list in database, I want to show the count on the screen. but it gives following error. I tried many solutions, but couldn't resolve.</p>
  
  <p>Following is the <strong>synchronizeStaffList Activity</strong> that calls <strong>SenkronizeEt</strong> Funtion using handler.
      public class synchronizeStaffList extends AppCompatActivity {</p>
  
  <pre><code>DatabaseHelper gksDatabase;
  
  TextView txtrecordValue;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_synchronize_staff_list);
  
  
      gksDatabase = new DatabaseHelper(this);
      txtrecordValue = (TextView) findViewById(R.id.txtrecordValue);
  
      final Handler handler = new Handler();
      handler.postDelayed(new Runnable() {
          @Override
          public void run() {
              //Do something after 100ms
              SenkronizeEt();
          }
      }, 500);
  
      final Handler handler2 = new Handler();
      handler2.postDelayed(new Runnable() {
          @Override
          public void run() {
              //Do something after 100ms
              AlertDialog.Builder builder;
              builder = new AlertDialog.Builder(synchronizeStaffList.this);
              builder.setCancelable(false);
              if (progressStaffListInfo == 0) {
                  builder.setMessage("Sunucu ile iletişim yok");
              } else if (progressStaffListInfo == 1) {
                  builder.setMessage("Sicil/Personel listesi güncellendi");
              }
              builder.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      // if user pressed "MINIMIZE", cancel this dialog &amp; minimize the application
                      // while attendance process will keep working in the back
                      // finish();
                      startActivity(new Intent(synchronizeStaffList.this, synchronize.class));
                      finish();
                  }
              });
              AlertDialog alert = builder.create();
              alert.show();
          }
      }, 5000);
  }
  </code></pre>
  
  <p>I uses second handler to show an alertbox.</p>
  
  <p>Following the <strong>SenkronizeEt</strong> Function that call <code>OkHttpHandler</code> <code>AsyncTask</code> function to get the <code>okHttpResponse/result</code>
      public int progressStaffListInfo = 0;  // 0: List no updated,   1: List updated,</p>
  
  <pre><code>private void SenkronizeEt() {
      progressStaffListInfo = 0;
  
      // Updating Staff List in device by calling webservices
      HashMap&lt;String, String&gt; Parametre = gksDatabase.GetParameter();
      final String urlStaffList = "http://127.0.0.1:8080/JAXRSJsonCRUDExample/rest/employees/" + Parametre.get("DeviceNo");
  
      OkHttpHandler handler = new OkHttpHandler();
  
      String jsonEmployeesList = null;
      try {
          jsonEmployeesList = handler.execute(urlStaffList).get();
      } catch (Exception e) {
          //tv.setText("sorry, something went wrong !");
      }
  
  
      if (progressStaffListInfo == 0) {
          Toast.makeText(synchronizeStaffList.this, "List Not Updated", Toast.LENGTH_SHORT).show();
      } else if (progressStaffListInfo == 1) {
          Toast.makeText(synchronizeStaffList.this, "List updated in database", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>Here is the <code>OkHttpHandler</code> <code>AsyncTask</code> function that call the <code>URL</code> to get the response and then update it in database.</p>
  
  <pre><code>public class OkHttpHandler extends AsyncTask&lt;String, Integer, String&gt; {
  
      OkHttpClient client = new OkHttpClient();
  
      @Override
      protected String doInBackground(String... params) {
  
          Request.Builder builder = new Request.Builder();
          builder.url(params[0]);
          Request request = builder.build();
  
          try {
              Response response = client.newCall(request).execute();
              // return response.body().string();
              String jsonData = response.body().string();
              //JSONObject Jobject = new JSONObject(jsonData);
              //JSONArray Jarray = Jobject.getJSONArray("employees");
              JSONArray Jarray = new JSONArray(jsonData);
  
              //get the length of the json array
              int limit = Jarray.length();
  
              if (limit != 0) {
                  gksDatabase.PersonsDelete();
                  progressStaffListInfo = 1; // Staff List updated
  
              }
  
              for (int i = 0; i &lt; limit; i++) {
                  JSONObject object = Jarray.getJSONObject(i);
  
                  //store the data into database
                  // SId:StaffID  SNo:StaffNumber     SN:StaffName    CNo:CardNumber
                  gksDatabase.PersonsSave(Integer.parseInt(object.getString("sid")), object.getString("sno"), object.getString("sn"),
                          object.getString("cno")
                  );
                  publishProgress((int) (((i+1) / (float) limit) * 100));
              }
  
              return jsonData;
          } catch (JSONException e) {
              progressStaffListInfo = 0;
          } catch (Exception e) {
              e.printStackTrace();
              progressStaffListInfo = 0;
          }
          return null;
      }
  
      @Override
      protected void onProgressUpdate(Integer... progress) {
          setProgressPercent(progress[0]);
      }
  }
  
  private void setProgressPercent(int progValue){
      txtrecordValue.setText(progValue);
  }
  </code></pre>
  
  <p>In above <code>AsyncTask</code> function, it gives error when it try to display the count of entries inserted in database.
  Actually, not only this. if I set any thing (Like progressbar or count) on different thread, even then it stops till the <code>asyncTask</code> finishes its work. As an example <code>AlertDialog</code> handler also starts when <code>AsyncTask</code> function finishes all its work.</p>
  
  <p>Following are the logs:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main android.content.res.Resources$NotFoundException: String resource ID #0x0
  at android.content.res.Resources.getText(Resources.java:249)
  at android.support.v7.widget.ResourcesWrapper.getText(ResourcesWrapper.java:52)
  at android.widget.TextView.setText(TextView.java:3796)
  at com.emiturk.gsk.synchronizeStaffList.setProgressPercent(synchronizeStaffList.java:172)
  at com.emiturk.gsk.synchronizeStaffList.access$100(synchronizeStaffList.java:25)
  at com.emiturk.gsk.synchronizeStaffList$OkHttpHandler.onProgressUpdate(synchronizeStaffList.java:167)
  at com.emiturk.gsk.synchronizeStaffList$OkHttpHandler.onProgressUpdate(synchronizeStaffList.java:116)
  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4810)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
  at dalvik.system.NativeStart.main(Native Method
  </code></pre>
  
  <p>Kindly help me out.</p>