Thursday, 27 June 2013

How to make a call to a phone number?(Android)

n Android, we can call any phone number by using Intent.ACTION_CALL. To call a phone number we need to access uses permission.
Here is the code that shows you how to call a particular phone number
public class ExampleApp extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:8304600889" )));
}
}
Here the sample phone number is '8304600889'. You can give any phone number here.
Add the below code in your AndroidManifest.XML file below to close the application tag.
<uses-permission android:name="android.permission.CALL_PHONE" />
By using "android.permission.CALL_PHONE" only we can place a call.
The output will look like

No comments: