【发布时间】:2016-05-09 02:55:31
【问题描述】:
我有这个代码sn-p:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < Build.VERSION_CODES.JELLY_BEAN) {
Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings");
intent.setComponent(cName);
} else {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
context.startActivity(intent);
}
为什么这在我的安卓手机(api level 15)上不起作用,但是当我用下面的代码替换它时,它就可以正常工作了?
Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings");
intent.setComponent(cName);
【问题讨论】:
-
请解释“这不起作用”是什么意思。另请注意,您只在
else块中调用startActivity(),而不是if块。 -
天哪!谢谢……太明显了,我看不到……
标签: android sdk android-api-levels