title: android - encode & decode string to be defined as a url
body: <p>How to encode and decode or parse the string to make it read as url?</p>
  
  <p>I've tried two things:</p>
  
  <ol>
  <li>URLencoder.encode</li>
  <li>Uri.encode</li>
  </ol>
  
  <p>but the response displays error 400</p>
  
  <p>Here, I have attached the code, look at the below</p>
  
  <pre><code> searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
              try {
                  progressDialog.setMessage("Mencari...");
                  showDialog();
                  jobList.clear();
  
                  String queryEncode = AppConfig.URL_GETJOBS + Uri.encode(query);
  
  
    //String queryEncode = URLEncoder.encode(query, "UTF-8");
  
  //String queryDecode = AppConfig.URL_GETJOBS + URLDecoder.decode(queryEncode, "UTF-8");
  
                  Log.d(TAG, "onQueryTextSubmit: " + getJobs(queryEncode));
                  getJobs(queryEncode);
                  homeRecyclerViewAdapter.notifyDataSetChanged();
                  hideDialog();
              } catch (UnsupportedEncodingException e) {
                  e.printStackTrace();
              }
              return false;
          }
  
          @Override
          public boolean onQueryTextChange(String newText) {
              return false;
          }
      });
  </code></pre>
  
  <p>Here response error 400 on logd: (<a href="https://i.stack.imgur.com/ZjbgY.png" rel="nofollow noreferrer">https://i.stack.imgur.com/ZjbgY.png</a>)</p>
  
  <p>Response in postman 200OK (successfull)(<a href="https://i.stack.imgur.com/YER6K.png" rel="nofollow noreferrer">https://i.stack.imgur.com/YER6K.png</a>)</p>