代码版本:
Android 2.3
代码路径:
packages\apps\Stk\src\com\android\stk\StkLaucherActivity.java
问题描述:
切换到飞行模式,SIM卡应用(STK)还可进入并点击菜单,但实际上点击菜单不会得到响应。
问题分析:
SIM卡应用没有针对飞行模式做判断,需要增加判断。
解决方案:
在STK的入口增加对飞行模式的判断,如果已经进入飞行模式,则不允许进入STK。增加一个提示框,在飞行模式下,提示用户不能使用STK。STK的入口可以通过接串口log来看,或者直接通过代码来看,StkLaucherActivity是STK的入口。新增代码将在StkLaucherActivity类中增加。
代码实现:
StkLaucherActivity.java
新增成员变量
private
AlertDialog mGenericErrorDialog;
protected
void onCreate(Bundle savedInstanceState) {
if(Settings.System.getInt(this.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,
0) == 1){
DialogInterface.OnClickListener clickListener;
OnCancelListener cancelListener;
clickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}};
cancelListener = new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
finish();
}};
mGenericErrorDialog = new AlertDialog.Builder(this)
.setMessage(getResources().getText())
.setPositiveButton(R.string.ok,
clickListener)
.setOnCancelListener(cancelListener)
.create();
mGenericErrorDialog.show();
return;
} super.onCreate(savedInstanceState);
Bundle args = new Bundle();
args.putInt(StkAppService.OPCODE,
StkAppService.OP_LAUNCH_APP);
startService(new Intent(this,
StkAppService.class).putExtras(args));
finish();
}
这里要注意OnCancelListener 是必须要有的,没有这个,Back键和HOME键的处理都会有问题。