我有这段代码:
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);
}
为什么我的Android手机(api等级15)没有这个功能,但当我用下面的代码替换它时,它运行正常?
Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings");
intent.setComponent(cName);
答案 0 :(得分:0)
if(currentapiVersion&lt; 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); context.startActivity(intent); } else { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); context.startActivity(intent); }
答案 1 :(得分:0)
你没有调用startActivity,如果Block出现问题的原因