end call

来源:互联网 发布:csgo国际服除了淘宝 编辑:程序博客网 时间:2024/05/16 13:48
//类加NeighboringCellInfo.aidl和ITelephony.aidl.
package cn.itcast.endcall;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import com.android.internal.telephony.ITelephony;import android.app.Activity;import android.os.Bundle;import android.os.IBinder;import android.os.RemoteException;import android.view.View;public class DemoActivity extends Activity {ITelephony  iTelephony;    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);            try {// 获取系统电话管理的服务 //反射,把系统类里面的方法获取,Method method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);//得到IBinder对象.IBinder binder = (IBinder)method.invoke(null, new Object[]{TELEPHONY_SERVICE});//返回到接口.iTelephony = ITelephony.Stub.asInterface(binder);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}    }        //方法.    public void endcall(View view){    try {//iTelephony.endCall();//点击按钮可以call  123.iTelephony.call("123");} catch (RemoteException e) {// TODO Auto-generated catch blocke.printStackTrace();}    //iTelephony.call("123");    }}


0 0
原创粉丝点击