Android-移动网络设置菜单(果冻豆)
以下代码不适用于Jelly Bean(Android 4.1): 相反,要开始设置,它什么都没有,你知道如何解决它吗 以下是解决方案:Android-移动网络设置菜单(果冻豆),android,networking,settings,android-4.2-jelly-bean,Android,Networking,Settings,Android 4.2 Jelly Bean,以下代码不适用于Jelly Bean(Android 4.1): 相反,要开始设置,它什么都没有,你知道如何解决它吗 以下是解决方案: final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.MobileNetworkSettings"); final Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); in
final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.MobileNetworkSettings");
final Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.addCategory(Intent.ACTION_MAIN);
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
谢谢大家:)试试看:
final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
下面的代码更简单,并在姜饼(2.3.7)和JB(4.1.2)上进行了测试
尝试添加标志\u ACTIVITY\u NEW\u TASK FLAG后,如果此操作不起作用,请使用简易方法将设备连接到调试器并手动启动操作\u DATA\u ROAMING\u设置,然后在日志中查看由系统启动的包名和活动名检查日志中的活动名,如com.android.phone/.SETTINGS??
final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
startActivityForResult(new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS), 0);