0

I'm trying to make an android project that will dial a fixed number. It is working when I'm using normal number like 01712364445 or something like that. But when I'm using this number *566# it is dialing to *567 that is # is missing.how to solve this ? My code is here...

    gp = (Button) findViewById(R.id.buttongp);
    gp.setOnClickListener(listener);


    }
OnClickListener listener = new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent dialerIntent = new Intent();
        dialerIntent.setAction(Intent.ACTION_CALL);
        dialerIntent.setData(Uri.parse("tel:*566# "));

        startActivity(dialerIntent);

    }
};
Sawpno
  • 85
  • 1
  • 2
  • 10

1 Answers1

0
Intent callIntent = new Intent(Intent.ACTION_CALL);
string pnd=uri.encode("#");     callIntent.setData(Uri.parse("tel:566 "+pnd));     startActivity(callIntent);

Try this
And make the constructor global before the main function

Edit: This code works

    Button b;
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    String pnd;
    @Override
    protected void onCreate(Bundle savedInstanceState)
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    b=(Button)findViewById(R.id.b1);

    OnClickListener ls=new OnClickListener(){

        @Override
        public void onClick(View p1)
        {
            {
                pnd=Uri.encode("#");
                callIntent.setData(Uri.parse("tel:*566 "+pnd));
                startActivity(callIntent);
            }
            // TODO: Implement this method
        }
    };
    b.setOnClickListener(ls);

    }

}

And the uri.encode(" #"); puts the pound sign in there retrieving ussd code. Follow procedures and concatenate the uri.encode("#");

Tested and works

Tested using AIDE for Android. It's how I create my apps from my smartphone.