我正在尝试创建一个应用程序,该应用程序将在选中复选框时自动接听电话。我已将 ITelephony.aidl 添加到 com.android.internal.telephony 并关注网络上的信息,但我似乎无法继续,它不会让我使用该answerRingingCall();
方法。错误我得到“无法解决电话服务”telephonyService.answerRingingCall();
有什么建议么?
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;
import com.android.internal.telephony.ITelephony;
public class AnswerActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CheckBox AnswerCheckBox = (CheckBox) findViewById(R.id.answerCheck);
AnswerCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if (buttonView.isChecked()) {
telephonyService.answerRingingCall();
Toast.makeText(getBaseContext(), "Calls will be answered",
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getBaseContext(), "Calls will NOT be answered",
Toast.LENGTH_SHORT).show();
}
}
});
}
}