Q:

how to get my android USSD program to work

am building a simple dialler to help me check my account balance but for some unknown reasons am getting some errors, i have a button on my xml which i have set its onclick element to sendMessage1 , but am getting error on my code with the phoneNum[1] telling me cannot reslove symbol phoneNum[1]. this is my code 
/**Called when the user clicks the Send button */

public void sendMessage1(View view){
    //example phoneNum[1] = "*556";
    String encodedHarsh = Uri.encode("#");
    startActivity(new Intent
            ("android.intent.action.DIAL",
                    Uri.parse("tel:"+ phoneNum[1]+ encodedHarsh)));
    //Do something in response to button
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mtn);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_mtn, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

A:

You have to do it doing this :
String encodedHarsh = "*" + "556" + Uri.encode("#");
startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + encodedHarsh)));

Note, don't forget to add uses-permisions on manifest

