【问题标题】:Android - Mobile network settings menu (Jelly Bean)Android - 移动网络设置菜单 (Jelly Bean)
【发布时间】:2012-07-02 17:34:42
【问题描述】:

以下代码不适用于 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);

改为开始设置,它什么都没有,知道如何解决吗?

这里是解决方案:

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

谢谢你们:)

【问题讨论】:

  • 添加FLAG_ACTIVITY_NEW_TASK标志后尝试

标签: android networking settings android-4.2-jelly-bean


【解决方案1】:

尝试:

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

【讨论】:

  • 如果这不起作用,那么简单的方法是将您的设备连接到调试器并手动启动 ACTION_DATA_ROAMING_SETTINGS 设置,然后在日志中查看系统启动的包名称和活动名称
  • 检查日志中的活动名称,例如 com.android.phone/.Settings ??
【解决方案2】:

下面的代码要简单得多,并在 Gingerbread (2.3.7) 和 JB (4.1.2) 上进行了测试

    startActivityForResult(new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS), 0);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 2012-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多