android-networking

Get Network on android.intent.action.BOOT_COMPLETED

亡梦爱人 提交于 2020-01-16 04:26:33
问题 I've an app that has a receiver of android.intent.action.BOOT_COMPLETED and start a private VPN. But when I receive a android.intent.action.BOOT_COMPLETED the network isn't ready yet. What can I do to start a android.intent.action.BOOT_COMPLETED and wait to have a network status? for example I can have a android.intent.action.BOOT_COMPLETED but the phone has no internet connection, or I can have a android.intent.action.BOOT_COMPLETED and 5 seconds later a internet Access. 回答1: You could

Http Authentication in android using volley library

假如想象 提交于 2020-01-14 09:08:06
问题 How to make Http Authentication for API using Volley library ? I tried the following code ....it throws Runtime Exception & Null pointer exception..Please provide suggestions String url = "Site url"; String host = "hostName"; int port = 80; String userName = "username"; String password = "Password"; DefaultHttpClient client = new DefaultHttpClient(); AuthScope authscope = new AuthScope(host, port); Credentials credentials = new UsernamePasswordCredentials(userName, password); client

Http Authentication in android using volley library

只愿长相守 提交于 2020-01-14 09:06:07
问题 How to make Http Authentication for API using Volley library ? I tried the following code ....it throws Runtime Exception & Null pointer exception..Please provide suggestions String url = "Site url"; String host = "hostName"; int port = 80; String userName = "username"; String password = "Password"; DefaultHttpClient client = new DefaultHttpClient(); AuthScope authscope = new AuthScope(host, port); Credentials credentials = new UsernamePasswordCredentials(userName, password); client

webserver on an android hotspot - what's its IP?

醉酒当歌 提交于 2020-01-13 10:54:46
问题 I want to setup an android phone as a wifi-hotspot, then run a webserver on it, and browse it from another phone connected to the hotspot. My phone isn't rooted, but I have termux, which has many unix utilities. I don't want to install an extra app. (But happy to write one!) I can view python's simple webserver on http://localhost (on the host), but not on the other phone. I tried using the public-facing IP of the host phone (checking it using whatsmyip-type webpages), but didn't work.

Square's Retrofit response parsing logic: streaming?

若如初见. 提交于 2020-01-10 19:38:13
问题 Could you please explain Square's Retrofit response parsing logic. I'm interested in case when we should receive & parse a big json (>100Kb) - will Retrofit wait while all content will be received from server and only than parse it, or it will start to parse it immediately while getting stream data? My goal is to speedup response processing. Are there any options about it available to configure? 回答1: As soon as the HTTP client parses the headers, the InputStream will be handed back to

non ASCII SSIDs in android

最后都变了- 提交于 2020-01-07 06:14:06
问题 Apparently SSIDs can contain UTF-8 chars and also control characters etc. IIUC to contain UTF-8 chars they must specify the SSIDEncoding field. I was under the impression that I can only get ASCII bytes till now. How should I handle the situation in Android ? Namely, how can I check the SSIDEncoding field from the ScanResult ? Do I need to ? Also what does ScanResult.SSID contain in these cases ( including the case an SSID includes non printable characters ) ? Related Why can't I detect a

Peer to peer connection in android

吃可爱长大的小学妹 提交于 2020-01-01 19:53:33
问题 Is there any way such that i can communicate with other android device in the same wifi network... for sharing files. Can I have list of all android device connected to same n/w? can any one refer me any api for doing that? or how can I make that thing happen?? this thing must be possible, Isn't it? I think this is possible in Android 4.0, using WiFiDirect but how that can be possible in lower level sdk's. Thank you 回答1: you should take a look at this WifiP2pManager 来源: https://stackoverflow

Android : Stopping a Bonjour service left running after the parent process quit abrubtly

一笑奈何 提交于 2019-12-30 08:49:07
问题 My app is essentially a background service that needs to occasionally register an NSD service ( Bonjour service) for the purpose of enabling discovery of a socket server run by the main background service (aka run by the app). If I am reading the Android Bonjour Service doc correctly, this is how you start the Bonjour service (abbreviated for conciseness): mNsdManager = Context.getSystemService(Context.NSD_SERVICE); mDiscoveryListener = new NsdManager.DiscoveryListener() mNsdManager

Android UnknownHostException Facebook SDK

不羁的心 提交于 2019-12-30 06:53:45
问题 Here is the situation. My app runs fine, and is able to establish connections with URLs. BUT after a few hours of leaving the app running, all of a sudden the Facebook requests are giving me the following error. 09-26 10:01:25.175: W/System.err(252): java.net.UnknownHostException: Host is unresolved: xyz.com:80 09-26 10:01:25.175: W/System.err(252): at java.net.Socket.connect(Socket.java:1037) 09-26 10:01:25.175: W/System.err(252): at org.apache.harmony.luni.internal.net.www.protocol.http

How to check Wifi is connected, but no Internet access in Android

百般思念 提交于 2019-12-30 01:01:06
问题 I would like to know why wifi is connected but there is no internet access in Android. How can i check it? My code is: ConnectivityManager cn=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nf=cn.getActiveNetworkInfo(); if(nf != null && nf.isConnected() ) { Flag2=false; Log.e("network--------", "1--------------"); if (cn.getActiveNetworkInfo().isConnectedOrConnecting()) {Log.e("network--------", "11111111111111--------------"); } else {Log.e("network--------",