Android Intent.ACTION_CALL, Uri

前端 未结 9 684
南笙
南笙 2020-12-05 16:12

I am trying to use the Intent.Action class. I know how to use the ACTION_VIEW to display a URL but I wanted to use the Intent.ACTION_DIAL to call number when th

相关标签:
9条回答
  • 2020-12-05 16:46

    try this

    String no = "536171839";
    Intent callintent = new Intent(android.intent.action.CALL);
    callintent.setData(Uri.parse("tel:" +no));
    startActivity(callintent);
    

    add this to your AndroidManifest.xml file

     <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
    
    0 讨论(0)
  • 2020-12-05 16:48

    To just open the dialer app (the user has to press the call button inside the dialer app; no additional permissions needed) use:

    String number = "7777777777";
    Uri call = Uri.parse("tel:" + number);             
    Intent surf = new Intent(Intent.ACTION_DIAL, call); 
    startActivity(surf);
    

    To open the dialer app and do the call automatically (needs android.permission.CALL_PHONE) use:

    String number = "7777777777";
    Uri call = Uri.parse("tel:" + number);             
    Intent surf = new Intent(Intent.ACTION_CALL, call); 
    startActivity(surf);
    
    0 讨论(0)
  • 2020-12-05 16:49

    Try this also

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

    Android Manifest

    <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
    
    0 讨论(0)
提交回复
热议问题