using android dialer in 3rd party app

前端 未结 2 1902
孤街浪徒
孤街浪徒 2020-12-04 00:26

guys. I am trying to build a voip app for android. I want to make use of the built-in android phone dialer. Can you guys give me some reference to it. I have been googling w

相关标签:
2条回答
  • 2020-12-04 01:14

    What you need to do is setup an Intent filter on the Activity you want to make the call. You do this inside your AndroidManifest.xml file. Modify your activity definition to include this intent filter:

    <intent-filter>
        <action android:name="android.intent.action.CALL" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="tel" />
    </intent-filter>
    

    Note: there are some alternative ways to call people (which can be seeing in the AndroidManifest.xml of the source I linked bellow, however this is the main one

    Adding this will give the user the option to use your app when making a call, and this can be set as the default app if the user wishes.

    You can then get the phone number by adding something like this code to your onCreate() method of your activity:

    final Intent i = getIntent();
    final Uri phoneUri = i.getData();
    

    phoneUri now contains tel:00000000000 and you can easily get the number out of the Uri object

    If you have problems in to future take a look at the android source. I got these bits of code from the phone app source if you want to take a look.

    0 讨论(0)
  • 2020-12-04 01:23

    This should open the dialer with new special permissions:

    Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:0000000000"));
    startActivity(i);
    

    That should open the dialer with the required telephone number already inserted.

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