Dear Pent,

          Now I'm able to accept the call programmatically without user
interaction.
We can do dat in two ways.

One way by implementing ITelephony.aidl.

Use the below code in the same package as specified and save as *
ITelephony.aidl*
*
*
package com.android.internal.telephony;

interface ITelephony {

    boolean endCall();

    void answerRingingCall();

    void silenceRinger();
}

And use the below method to accept the call in ur code.

private void answerPhoneAidl(Context context) throws Exception {
                // Set up communication with the telephony service (thanks
to Tedd's Droid Tools!)
                TelephonyManager tm = (TelephonyManager) getSystemService(
TELEPHONY_SERVICE);
                Class c = Class.forName(tm.getClass().getName());
                Method m = c.getDeclaredMethod("getITelephony");
                m.setAccessible(true);
                ITelephony telephonyService;
                telephonyService = (ITelephony)m.invoke(tm);

                // Silence the ringer and answer the call!
                telephonyService.silenceRinger();
                telephonyService.answerRingingCall();
        } I read this way of accepting the call is not supported in all
versions of android. I dont know for sure. The other way is just use the
below method in ur code when ever u want to accept the call.  private
voidanswerPhoneHeadsethook
(Context context) {
                // Simulate a press of the headset button to pick up the
call
                Intent buttonDown = new
Intent(Intent.ACTION_MEDIA_BUTTON);
                buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
                context.sendOrderedBroadcast(buttonDown,
"android.permission.CALL_PRIVILEGED");

                // froyo and beyond trigger on buttonUp instead of
buttonDown
                Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);

                buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(
KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
                context.sendOrderedBroadcast(buttonUp,
"android.permission.CALL_PRIVILEGED");
        } hope this will help you, Cheers, Saran

On Thu, May 17, 2012 at 1:40 PM, Pent <supp...@apps.dinglisch.net> wrote:

> > As far as I know that API needs a permission these days.
>
> Sorry, I meant 'needs a permission which isn't granted'.
>
> Pent
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to