I am trying to create a way a user can contact a friend via sms, email and a phone call. I have completed the email and SMS part. I have figured out how to use createChooser to select how a message will be sent using either email or text message, this is achieved by clicking on a button, the following code is how I do this:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{""});
i.putExtra(Intent.EXTRA_SUBJECT, "Check out my awesome score!");
i.putExtra(Intent.EXTRA_TEXT , "I am playing this awesome game called Tap the Button, and I just scored the incredible highscore of " +s+ " Taps!!\n\nCan you beat it!?");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Fail.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
My aim is to have a button that opens a form like this does where the user can select a phone number from the phones phone book.
The above email and text code allows me to choose which way to send the message from the available ways to do it on this phone, if I select email it creates the form using the putExtra. I want one put extras to click on and select a phone number from the phones address book. Here is my latest attempt at this:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setType("text/plain");
callIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, new String[]{""});
try {
startActivity(Intent.createChooser(callIntent, "CAlling..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Fail.this, "There are no call clients installed.", Toast.LENGTH_SHORT).show();
}
When I run the code it catches an exception, saying there is no call client. I have this permission in my android manifest:
uses-permission android:name="android.permission.CALL_PHONE"
I would appreciate any advice on this, thanks.
Calling is acheived by using the tel: scheme, not using an extra: