title: How to Get Response from USSD code from Android?
body: <p>I have written an application that uses ussd code. I want to send a request for a ussd but I don't know how to get the data and save it in a String.</p>
  
  <p>sample code: </p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button btn = (Button) findViewById(R.id.button1);
  
      btn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              String encodedHash = Uri.encode("#");
              String ussd = "*141*1" + encodedHash;
              startActivityForResult(new Intent("android.intent.action.CALL",
                      Uri.parse("tel:" + ussd)), 1);
  
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // TODO Auto-generated method stub
      super.onActivityResult(requestCode, resultCode, data);
  
      Toast.makeText(getApplicationContext(),
              "USSD: " + requestCode + "  " + resultCode + " ", 1).show();
  
      if (requestCode == 1) {
  
          if (resultCode == RESULT_OK) {
              // String result=data.getStringExtra("result");
              String dd = data.toString();
              Toast.makeText(getApplicationContext(), dd, 1).show();
          }
  
      }
  </code></pre>
  
  <p>Screenshots application:
  <img src="https://i.stack.imgur.com/8qfXT.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/nlg4s.png" alt="enter image description here"></p>
  
  <p>how to Resolve my Problem?</p>