android-wifi

WiFi Direct status

怎甘沉沦 提交于 2019-12-01 13:06:55
问题 Is it possible to specifically check that whether WiFi Direct is On or Off ? I wrote a code which can only update about the wifi status that whether it is connected or not,no matter it is Access point or WiFi Direct ConnectivityManager connManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mWifi.isConnected()) { } if (!mWifi.isConnected()) { } I want to specifically

how to check that internet on local wifi is available or not?

笑着哭i 提交于 2019-12-01 11:08:37
问题 I need to check oin my app that internet on local wifi is available or not , i tried requestRouteToHost but it always returning false , so please help 回答1: Here is the best way to test if the device has INTERNET connection period. public static boolean hasActiveInternetConnection(Context context) { if (isNetworkAvailable(context)) { try { HttpURLConnection urlc = (HttpURLConnection) (new URL("http://www.google.com").openConnection()); urlc.setRequestProperty("User-Agent", "Test"); urlc

need to run service while device got wifi/data connection

白昼怎懂夜的黑 提交于 2019-12-01 11:06:38
Last time, I use following coding to run background service. Intent intent = new Intent(InitActivity.this, GetService.class); PendingIntent pintent = PendingIntent.getService(InitActivity.this, 0, intent, 0); Calendar calendar = Calendar.getInstance(); AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 50 * 1000, pintent); return getZipInfo.toString(); to make better performance, I want to run my background service once device is connect WIFI/data connection. To make clear, if device is not connect

Change Configuration of mobile Hotspot

左心房为你撑大大i 提交于 2019-12-01 11:04:47
问题 I'm trying to run a hotspot with a new name and open accessibility. wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); wifiConfig.SSID = "\"MySSID\""; wifiConfig.networkId = 1; methodNum = getMethodNumber("setWifiApEnabled"); try { wmMethods[methodNum].invoke(wifiManager, wifiConfig, true); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1

Connecting to WiFi network automatically in Android 5 and 6

限于喜欢 提交于 2019-12-01 10:56:02
Been struggling with connecting to WiFi network in Android 5 and 6 for a while and other similar questions don't seem to work for me. I could get the same code working in Android 4.4.2 Adding the code snippet below. String networkSSID = getSsid(); String networkPass = getNetworkPass(); WifiConfiguration conf = new WifiConfiguration(); conf.SSID = "\"" + networkSSID + "\""; conf.status = WifiConfiguration.Status.ENABLED; conf.priority = 40; conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN); conf.allowedProtocols.set(WifiConfiguration.Protocol.WPA); conf.allowedKeyManagement.set

Cordova - Checking WIFI connection to internet

允我心安 提交于 2019-12-01 09:47:29
问题 I use Cordova to develop a smartphone application. In this app, I need to check the internet connection before send request to a server. In order to do that I use the Cordova Connection API, but in the case that the device is connected to a WIFI network with no Internet connection, this API say that we have WIFI connection, is there any way to check if internet is available on the WIFI network ? 回答1: Send an Dummy ajax request before you send the actual request, If you get and Error Code as

Is it possible to programatically enable wifi on Android 10 devices?

北城以北 提交于 2019-12-01 07:28:58
问题 Since setWifiEnabled is deprecated on Android 10, how does one programatically enable wifi on Android 10 devices? Is it not possible to programatically enable wifi at all on Android 10+ (SDK 29) ? 回答1: No, This is not possible to enable or disable Wi-Fi programmatically from Android-10 API level 29 [ Until google provides an alternative solution ]. For applications targeting Build.VERSION_CODES.Q or above, this API will always return false and will have no effect. If apps are targeting an

WiFi state is not enabling

淺唱寂寞╮ 提交于 2019-12-01 03:58:01
I am trying to create a widget for enabling and disabling the wifi. if(myWifiManager.isWifiEnabled()){ System.out.println("Toggle Wifi Enabled going to disable"); myWifiManager.setWifiEnabled(false); } else{ System.out.println("Wifi Disabled going to enable "); myWifiManager.setWifiEnabled(true); System.out.println("WI: "+myWifiManager.isWifiEnabled()); } This is the code i am using the disabling part is working fine but the enabling part is not working fine. Soon after enabling the wifi i am printing the wifi state i am getting it as false. Here is how to turn on and turn off wifi in android.

Is it possible to connect two or more WiFi Direct groups?

时光怂恿深爱的人放手 提交于 2019-11-30 22:54:54
I am currently experimenting with WiFi-Direct (WiFiP2p) for a project I'm working on and wanted to know if one can create bridge between groups, thus joining them together? Based upon the white paper released by the WiFi Alliance, it should be possible (though "The P2P Specification does not describe the mechanism for this capability – implementation is specific to the vendor"). I have looked through the internet and have found some answers ( this , this , etc.) but I feel that none are particularly conclusive. Looking at Andoid's API hasn't helped much either. The scenario I'm trying to

How to handle network change between wifi and mobile data?

大城市里の小女人 提交于 2019-11-30 17:11:31
I am building a VoIP app.During a VoIP call when user switches between WiFi to mobile data i have a problem handling the scenario. In my call screen activity I have registered for receiver which helps me get notified about the network change scenarios. This is the code which I am using for detecting change in networks in the onRecieve Method. conn_name is private class level variable holding previous connection name. ConnectivityManager connectivity_mgr = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)); NetworkInfo net_info = connectivity_mgr.getActiveNetworkInfo