android-wifi

android turning on wifi programmatically

梦想与她 提交于 2019-11-27 01:40:53
问题 I am trying to turn add a wifi network programmatically and to connect to that network. My code works fine if the wi-fi is already turned on. If wi-fi is off, what i see wifimanager.addtonetwork() fails and when i see the wifi settings for the phone, i can see the status as scanning If i try to connect again it works fine. Please see code below. Please help private int changeNetwork(NetworkSetting setting) { // If the SSID is empty, throw an error and return if (setting.getSsid() == null ||

Send request over WiFi (without connection) even if Mobile data is ON (with connection) on Android M

橙三吉。 提交于 2019-11-27 01:02:51
问题 I have to send UDP packets to a WiFi module (provided with own AP) with no internet connection but when I connect the mobile with the AP, Android redirects my packets on the mobile data interface because it has got internet connection. I've used the code below to do my job but it seems not working on Android M. @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setWifiInterfaceAsDefault() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context

How to provide option to select wi-fi or GPRS for network connectivity in android app

萝らか妹 提交于 2019-11-26 23:05:53
问题 In my app i want to provide the user with the option to choose wi-fi / GPRS for network connectivity to the web server. May be answers to the following ques solve my prob ... 1. How to check which is the current default network connectivity option enabled. 2. How to enable wi-fi/GPRS on user selection or (disable the wi-fi if user chooses GPRS - if only this option will be required for GPRS to work) or is there some other way around to do this ? 回答1: Try this: ConnectivityManager connManager

Android Studio - Android Emulator Wifi Connected with No Internet

試著忘記壹切 提交于 2019-11-26 22:52:03
问题 I have wasted a whole day trying out different solutions floating around in SO and other place mentioned to enable wifi on the android emulator but to no avail. Can anybody help me figure out how do I enable internet on my android emulator? I have Nexus 5X API 27 and target being Android 8.1 (Google Play) and Nexus 5 API P and target being Android 7.1.1. I believe there should be a way to enable internet on it or else the whole point of providing virtual wifi on the emulator seems to be waste

how to install CA certificate programmatically on Android without user interaction

与世无争的帅哥 提交于 2019-11-26 22:36:13
问题 I'm trying to install certificates without prompting the user. I know this is not good practice, but that's what PM wants. Using KeyChain.createInstallIntent(), I can get Android to launch the certificate installation dialog by calling startActivity . However, when I pass the intent to sendBroadcast , nothing happens. Maybe the platform doesn't support this for security reasons? String CERT_FILE = Environment.getExternalStorageDirectory() + "/test/IAT.crt"; Intent intent = KeyChain

Android 2.3 wifi hotspot API

拟墨画扇 提交于 2019-11-26 21:42:39
What is the API call I need to make in Android 2.2 (Froyo) to create a Wifi hotspot (as seen in the Tethering and Portable Hotspot settings item). There is no official API, but you can use reflection to handle it. I know some say, it's not recommended, however imho I say, screw it if Google doesn't want to provide an API for whatever reason. Below is the code of an activity I used in my application, where the user can enable/disable the Wifi AP. When you enable Wifi AP, usually the regular Wifi will be turned off, so after the user disables the Wifi AP again, we'll be activating regular wifi

Android : Reconnect to Wi-Fi after entering coverage area while screen turned off

旧街凉风 提交于 2019-11-26 20:47:02
问题 I have been struggling with automatically turning on Wi-Fi as soon as the device is within range of an access point without turning on the screen. It has been very frustrating to test and figure out a solution, especially since different devices have completely different results. Base Test Keep the screen turned off during this test. The application should hold a WifiLock. Walk out of WiFi coverage and stay there for a minute. Walk back into coverage. Result : The Wifi is not reconnected

How to be notified when a peer is no longer available in the Wi-Fi Direct range?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 20:17:23
问题 I am developing an Android application based on the use of Wifi Direct API. I have registered in my Activity a BroadcastReceiver in order to be notified about the following Wifi Direct events: WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION I believed that any change in the list of peers (the inclusion or exclusion of a peer in the Wifi Direct range)

Getting data speed of wifi/mobile network programmatically [duplicate]

这一生的挚爱 提交于 2019-11-26 20:00:59
问题 This question already has answers here : How to get link speed programmatically? (3 answers) Closed 4 years ago . How do I get the data speed of wifi/mobile network programmatically in my application. 回答1: Here's the code for getting the WiFi speed: WifiManager wifiManager = getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured using WifiInfo.LINK

Android get IP-Address of a hotspot providing device

浪尽此生 提交于 2019-11-26 19:56:14
问题 I'm currently using public static String getLocalIPAddress(WifiManager wm){ return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); } to get the IP-Address of the executing devices. That works fine if the device is connected to a "common" wlan-network as well as the device is connected to a wifi network which is hosted by an other android device via hotspot. If the device is not connected to any wifi network "0.0.0.0" is returned (correct). But if the device is hosting a wifi