How can I call a number from button press in Android?

前端 未结 7 1261
轻奢々
轻奢々 2021-01-03 13:44

I\'m very much a beginner at this and I\'m struggling to get this to work.

When button is pressed, I simply want the dialer to open with the specified number automa

相关标签:
7条回答
  • 2021-01-03 13:56

    Make sure you have added the

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

    tag at a correct level in the AndroidManifest.xml file (outside the <application ... /> tag but within the <manifest ... /> tag):

    0 讨论(0)
  • 2021-01-03 13:57

    Add the following in the manifest file and it should work fine -

        <uses-permission android:name="android.permission.CALL_PHONE"/>
    
    0 讨论(0)
  • 2021-01-03 14:03
    String number = "12345678";
        Intent intent = new Intent(Intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:" +number));
        startActivity(intent);
    

    You need to add this Permission to your manifest.

    <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
    
    0 讨论(0)
  • 2021-01-03 14:07

    i think you Must add <uses-permission android:name="android.permission.CALL_PHONE" /> in Manifest.

    0 讨论(0)
  • 2021-01-03 14:11

    If you want the dialer to open with the number use ACTION_DIAL

    Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + phoneno));  
    

    You do not need any permission

    0 讨论(0)
  • 2021-01-03 14:13

    Try this.

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

    Also, add the permission android.permission.CALL_PHONE in your manifest file.

    0 讨论(0)
提交回复
热议问题