简体   繁体   中英

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.

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 . 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.

<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. This receiver intercepts every call to CALL_PRIVILEGED or CALL actions on the device regardless of what app is the one targeted.

The destination number can be found on the receiver's intent extras in Intent.EXTRA_PHONE_NUMBER.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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