问题描述
编写了一个小程序,当您单击通话次数时,一切都很好,但是在另一部手机上进行了测试,当您刚刚离开程序时,但后来我想起了他有双重sim.Tak当您运行程序为1或2时,如何将其放入标准sim卡?或给出选择,用户将如何选择SIM卡给他打电话?尝试使用getDeviceId(),写道非静态方法...".用于拨打电话的那部分代码:
Wrote a little program, when you click on the number of calls, and all would be well in this tale, but tested it on another phone, and when you just departed from the program, but then I remembered that he had dual sim.Tak how to put that to standard sim card when you run the program was 1 or 2? or given a choice, what would the user chose how the sim card to call him? Tried to use getDeviceId (), writes that "Non-static metod ...". That part of the code that is used to make a call:
final Intent calling1 = new Intent(Intent.ACTION_CALL);
call1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
calling1.setData(Uri.parse("tel:5555"));
startActivity(calling1);
}
});
在android 4.2.1上,按一下应用程序附带的所有按钮,会写一个错误,也要修复它,不知道吗?
On android 4.2.1 by pressing all comes with the application, writes an error, how to fix it too, do not tell?
推荐答案
执行以下操作:
Intent i = new Intent(Intent.ACTION_CALL)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// set active SIM
i.putExtra("simSlot", SimIndex); // <-------------------
i.setData(Uri.parse("tel:" + phone));
startActivity(i);
其中SimIndex为0或1时为&第二张SIM卡.
Where SimIndex is 0 or 1 for first & second SIM cards, respectively.
在某些设备上,SIM卡设置行将为:
On some devices the SIM setting line will be:
// set active SIM
i.putExtra("com.android.phone.extra.slot", SimIndex)
您可能想创建一个以之前的方法,如果失败,则尝试后者.
You would probably want to create a fallthrough mechanism that start with theprior way and, if fails, attempts the latter.
希望有帮助.
这篇关于如何为用户提供使用哪个SIM卡调用程序的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!