简体   繁体   English

从Android中的拨号获取号码?

[英]Get number from dial in Android?

I am working on an application in which I have to make call from my application using my PHP server. 我正在开发一个应用程序,其中必须使用我的PHP服务器从应用程序进行调用。

I have a condition in which, whenever user presses the Green call button of Android Device and after dialing number, I have to give user an option to call from my App or normal SIM . 我有一种条件,每当用户按下Android设备的绿色通话按钮并拨打号码后, 我都必须给用户一个从我的App或普通SIM卡拨打电话的选项 I have done that too. 我也这样做了。 Now I want to get the number which I have dialed on the dialer before switching to the application . 现在, 我想获得在切换到应用程序之前在拨号器上拨打的号码

Means if User selects my application to call then I must have number dialed on the phone Dial. 表示如果用户选择我的应用程序进行呼叫,那么我必须在电话拨号上拨打号码。

I am using the below code to generate the pop up to use my application for calling. 我正在使用以下代码来生成弹出窗口,以使用我的应用程序进行调用。 The code is written as Intent filter in my manifest inside the specific activity. 该代码在特定活动的清单中写为Intent过滤器。

<activity
            android:name="com.tv.longdistcall.PlaceLongDistCall"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.CALL_BUTTON" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.CALL_PRIVILEGED" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="tel" />
            </intent-filter>
        </activity>

Please suggest me, how to get the number dialed on the dialer before switching to the activity. 请建议我,在切换到活动之前如何获取在拨号器上拨打的号码

You need to create a new BroadcastReceiver with NEW_OUTGOING_CALL intent filter. 您需要使用NEW_OUTGOING_CALL意向过滤器创建一个新的BroadcastReceiver。 This receiver intercepts every call to CALL_PRIVILEGED or CALL actions on the device regardless of what app is the one targeted. 该接收器会拦截设备上对CALL_PRIVILEGED或CALL操作的每次调用,无论目标是哪个应用。

The destination number can be found on the receiver's intent extras in Intent.EXTRA_PHONE_NUMBER. 可以在收件人的Intent.EXTRA_PHONE_NUMBER的意图附加信息中找到目标号码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM