Android的应用程序设置连接类型 [英] Android application setting connection type

查看:196
本文介绍了Android的应用程序设置连接类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Android编写应用程序。我的问题是,我希望它迫使GPRS连接,并且不使用Wi - Fi无线。我有这样一个下面的解决方案,而这将导致在启动应用程序的崩溃。

  ConnectivityManager CM =
    (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
CM.setNetwork preference(ConnectivityManager.TYPE_MOBILE);

我还增加了以下设置行到清单文件。

 使用许可权的android:NAME =android.permission.WRITE_SETTINGS
使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE
使用许可权的android:NAME =android.permission.CHANGE_NETWORK_STATE
使用许可权的android:NAME =android.permission.CHANGE_CONFIGURATION
使用许可权的android:NAME =android.permission.WRITE_SECURE_SETTINGS

有谁知道的问题,或答案设置连接类型?


解决方案

  

我的问题是,我想它迫使
  在GPRS连接,而不是使用Wi
  网络连接。


今天是不可能的Andr​​oid,对不起。

I'm writing an application for android. My problem is that I want it to force the connection in GPRS and not use wi fi. I have a solution like below, but this causes the crash of the application at start.

ConnectivityManager CM = 
    (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
CM.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);

I also added the below setting lines into manifest file.

uses-permission android:name="android.permission.WRITE_SETTINGS" 
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" 
uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"
uses-permission android:name="android.permission.CHANGE_CONFIGURATION" 
uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" 

Does anyone know the problem, or an answer to set connection type?

解决方案

My problem is that I want it to force the connection in GPRS and not use wi fi.

That is not possible in Android today, sorry.

这篇关于Android的应用程序设置连接类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆