我正在尝试使用拨号器 Intent 获得结果startActivityForResult()
下面是我的拨号器意图代码。
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:123456789"));
startActivityForResult(intent, 1234);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 1234){
if (resultCode == Activity.RESULT_OK){
Toast.makeText(getApplicationContext(), "result ok", Toast.LENGTH_LONG).show();
}else if (resultCode == Activity.RESULT_CANCELED){
Toast.makeText(getApplicationContext(), "Result Cancelled", Toast.LENGTH_LONG).show();
}
}
}
每当我返回我的活动时,都会触发 Result Canceled Toast。
提前致谢。