I'm very much a beginner at this and I'm struggling to get this to work.
When button is pressed, I simply want the dialer to open with the specified number automatically inputted.
So far I've tried the following:
Button btn_call_us = (Button) findViewById(R.id.btn_call_us);
btn_call_us.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:00000000"));
startActivity(callIntent);
}
});
I've also tried:
Button btn_call_us = (Button) findViewById(R.id.btn_call_us);
btn_call_us.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String phoneno="00000000";
Intent i=new Intent(Intent.ACTION_CALL,Uri.parse(phoneno));
startActivity(i);
}
});
I've added the permission ACTION_CALL to the manifest.
Whenever I click the Call button the app force closes.
Any assistance would be greatly appreciated.
Thank you!