【发布时间】:2011-05-13 09:03:44
【问题描述】:
我正在尝试将一些数据传递给我正在呼叫的电话。 有什么办法可以做到这一点吗? 我并不真正关心数据的类型(一位就足够了), 只要我能识别它并触发特定的动作。
发送代码:
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");
}
}
【问题讨论】:
-
你的代码的结果是什么?您的电话是否收到?日志中的内容是什么?
-
@exception 没有例外,但结果是假的——这是有道理的,因为 android 总是在 extra 中发送一些东西,比如 phonenumber(如果我没记错的话)
标签: android phone-call