我想将一些数据传递给我打来的电话。 有什么办法可以做到这一点? 只要我能识别它并触发特定的操作,我并不在意数据的类型(单个位就够了), 。Android:您可以通过电话来发送/接收数据吗?
发送代码:
Intent call = new Intent();
call.setAction(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + contact.getNumber()));
call.putExtra("Boolean", true);
startActivity(call);
收到代码:
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
if (extras.getBoolean("Boolean")){
Log.d("BOOL", "true");
} else {
Log.d("BOOL", "false");
}else {
Log.d("BOOL", "nothing");
}
}
你的代码的结果是什么?你打来的电话是否收到了?它在日志中说什么? – exception01 2011-05-13 09:11:16
@exception没有例外,但结果是错误的 - 这是有道理的,因为android总是发送一些额外的东西,如phonenumber(如果我没有弄错) – Andreas 2011-05-13 14:04:19