Send user to data usage settings window

六月ゝ 毕业季﹏ 提交于 2019-12-24 00:11:55

问题


Till android 5, user could turn on cellular data from the roaming settings window. So Settings.ACTION_DATA_ROAMING_SETTINGS is used to send user there.

In lollipop though, you no longer can do that and the option to turn on mobile data is under data usage window. Question is, how can send user to that window as Settings don't seem to have anything to help me.

Thanks


回答1:


I don't think there is currently a way to show programmatically the Settings - Data Usage screen on Lollipop 5.0.

The class android.provider.Settings contains all possible values for Intent actions.

I tried all of these values by they did not lead to Data Usage:

  • ACTION_NETWORK_OPERATOR_SETTINGS
  • ACTION_WIRELESS_SETTINGS
  • ACTION_DATA_ROAMING_SETTINGS

As a a fallback you can either show the generic Settings screen (ACTION_SETTINGS) or show a Toast notification telling the user to enable the Mobile Data Network.




回答2:


While there is no direct action available, you can launch the data usage activity directly. Here is how it works

Intent intent = new Intent();
intent.setComponent(new ComponentName(
                            "com.android.settings",
                            "com.android.settings.Settings$DataUsageSummaryActivity"));


来源:https://stackoverflow.com/questions/27859457/send-user-to-data-usage-settings-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!