How to run android.intent.action.CALL in a service?

How to run android.intent.action.CALL code (to get USSD)?

My code is:

 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, problem with startActivityForResult() .

+4
source share
1 answer

This is the intention to call

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

& Do not miss adding permission to Maniefiest

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

Source: https://habr.com/ru/post/1390198/


All Articles