//类加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 block
e.printStackTrace();
}
}
//方法.
public void endcall(View view){
try {
//iTelephony.endCall();
//点击按钮可以call 123.
iTelephony.call("123");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//iTelephony.call("123");
}
}