user3240144
user3240144

Reputation: 1

android programming for triggering phone call

i have been trying this prblemstatement. when triggered with a bluetooth file transfer android phone has to make an automatic phone call to a given number .Can any help with the coding in android for this purpose.

I need code to start phone call from bluetooth like when i send data from it to phone then the phone should automatically call apredefined number.

Upvotes: 0

Views: 375

Answers (2)

Swayam
Swayam

Reputation: 16354

public void call() {   
            Intent callIntent = new Intent(Intent.ACTION_CALL);          
            callIntent.setData(Uri.parse("tel:"+phone));          
            startActivity(callIntent);  
   }

is the function you need to call as soon as the transfer is triggered.

Upvotes: 1

Nathua
Nathua

Reputation: 8826

 String phone = "tel:" + "03242342342" ;
 Intent intent = new Intent(Intent.ACTION_CALL);
 intent.setData(Uri.parse(phone));
 startActivity(intent);

you need to add permission for that.

 <uses-permission android:name="android.permission.CALL_PHONE" />

or better approach to use

Intent.ACTION_DIAL

as intent filter in order to avoid permission, ACTION_DIAL will choose appropriate app for phone calling.

Upvotes: 0

Related Questions