user1029593 user1029593 - 1 month ago 10
Android Question

How to launch android.intent.action.CALL in service?

How to launch

android.intent.action.CALL
(to get USSD) code in service?

My Code:

protected void call(String phoneNumber) {
try {
startActivityForResult(
new Intent("android.intent.action.CALL", Uri.parse("tel:"
+ phoneNumber)), 1);
} catch (Exception eExcept) {
//this.view.append("\n\n " + "\n" + eExcept.toString());
}
}


This code does not work, the problem with
startActivityForResult()
.

Answer

This is the intent for call

 Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phoneno));
   startActivity(intent);

& Dont miss the Add permission in Maniefiest

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