endCall

来源:互联网 发布:0基础学美工 编辑:程序博客网 时间:2024/05/01 23:15

package com.android.internal.telephony;

import android.os.Bundle;
import java.util.List;

/**
 * Interface used to interact with the phone.  Mostly this is used by the
 * TelephonyManager class.  A few places are still using this directly.
 * Please clean them up if possible and use TelephonyManager insteadl.
 *
 * {@hide}
 */
interface ITelephony {

    /**
     * End call or go to the Home screen
     *
     * @return whether it hung up
     */
    boolean endCall();
}

------------------------------------------------------------------

    private void endCall() {

//            IBinder biner = (IBinder) getSystemService(Context.TELEPHONY_SERVICE);
            try {
                Class clazz = BlockService.class.getClassLoader().loadClass("android.os.ServiceManager");
                Method getService = clazz.getDeclaredMethod("getService", String.class);
                IBinder  binder = (IBinder) getService.invoke(null, Context.TELEPHONY_SERVICE);
                ITelephony itm = ITelephony.Stub.asInterface(binder);
                itm.endCall();
                Log.d(TAG, "Itm :" + itm);
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
0 0
原创粉丝点击