简体   繁体   中英

How can I initiate a call on the press of a Button?

I am in the process of building an app for my business. I would like to include telephone numbers and when a user presses the telephone button - I would like for that to call our business.

My question is.. is there a way to set up a button that when pressed...will call us?
I am using Eclipse
I am using Windows XP
I am using android 3.2

I know it is very easy to do using jquery in Dreamweaver 6.0...but I want to make my app better -- so I am trying to pick up Java along the way of developing this app.

Yes you can do this and it is incredibly easy to do. Essentially all you need is this intent:

String phoneNumber = "tel:123456789"
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(phoneNumber));
startActivity(callIntent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM