Although some elements of telephony development can be quite complicated, Android provides a built-in Phone Application that we can call on from our own applications by making use of an Intent object to call an activity in one application from another.
This is a quick and easy exercise with very little coding and a single class. Start up a new project with Eclipse and open up the main Java activity source.
There are just three lines to add to our
onCreate()
method and they can be seen here beneath thesetContentView()
statement:@Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main); Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("content://contacts/people/13")); startActivity(intent); }
That really is all there is to it. Run the project on a handset to test this properly. If you have fewer than 13 contacts on your phone, adjust the value in the code to accommodate...