English 中文(简体)
你们如何在方案上结束对2.3+的呼吁?
原标题:How do you programmatically end a call on 2.3+?
  • 时间:2012-04-07 12:09:58
  •  标签:
  • android

Up to Android 2.2 I know I can use reflection and terminate the call through getITelephony.

However, as of 2.3 this no longer works because even if you grant the MODIFY_PHONE_STATE permission to your app, it s now a system app only permission: https://stackoverflow.com/a/5095956/821423

尽管如此,这还是有可能的,因为在果园市场的大量申请正在对海运公会进行罚款,例如:

https://play.google.com/store/apps/details?id=com.androminigsm.fscifree&hl=en/a>

So the question is, how do they do it? I know I can pick up the call using simulating a headset hook, but I can t figure out how to end the call.

谢谢。

最佳回答

在经过许多灵魂研究之后,我确实认识到,实际上确实是 d。 在加边,StackOverflow似乎没有人注意到这一点。 MODIFY PHONE_STATE 自2.3+以来,不再从事 silence默工作,但Call只是罚款。

因此,解决办法是表达沉默的呼声。

相信我刚刚花了一周时间! 我试图更新其他问题,因为似乎有吨 SO在SO中,因此不可能用反思来不再发出呼吁。

问题回答

1. 私人真空端Call(有限停产时间){

TelephonyManager telephony = (TelephonyManager) srvs
            .getSystemService(Context.TELEPHONY_SERVICE);
    Class c;
    final com.android.internal.telephony.ITelephony telephonyService;
    try {
        c = Class.forName("android.telephony.TelephonyManager");//telephony.getClass().getName());
        Log.i("TelephonyClass Name", telephony.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        telephonyService = (ITelephony) m.invoke(telephony);
        TimerTask task = new TimerTask() {

            @Override
            public void run() {
                try {
                    if (telephonyService.isIdle()
                            || telephonyService.isOffhook()
                            || telephonyService.isRinging())
                        telephonyService.endCall();
                } catch (RemoteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        };
        long delay = Integer.parseInt(cutofftime) * 1000;
        new Timer().schedule(task, delay);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签