Android的 - 移动网络设置菜单(果冻豆)果冻、菜单、网络、Android

2023-09-05 06:27:15 作者:人未来,心己亡

以下code是不工作的果冻豆(安卓4.1):

following code is not working for Jelly Bean (Android 4.1):

final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings");
final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

而启动的设置,它doesn't什么,知道怎样解决呢?

Instead to start setting , it doesn´t nothing, any idea how to solve it?

下面是解决办法:

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);