android-networking

Ethernet Connectivity through Programmatically (Android) (Rooted Device)

醉酒当歌 提交于 2019-12-28 11:46:46
问题 I have a small issue regarding Ethernet . My three questions are: Can we programmatically Turn-On/Off Ethernet ? Can we programmatically Enable/Disable Ethernet ? Can we programmatically Connect Ethernet ? The above Questions are done with the Wifi . Like We can programmatically Turn-On/Off Wifi . We can programmatically Enable/Disable Wifi . We can programmatically Connect Wifi using WifiManager . Does android provides any EthernetManager like as WifiManager to handle Ethernet ? Or, if this

Response in 202 STATUS in Retrofit2.0

我的梦境 提交于 2019-12-25 18:34:30
问题 i want to convert the Response in to JSON and show it to the User .I was able to display 200 response but in 202,i am failed. { Log.d(TAG, "RESPONSE CODE" + response.code()); if (response.code() == 200) { Gson gson = new Gson(); SuccessResponse signupResponse = response.body(); String sSignupResponse = gson.toJson(signUpResponse, SuccessResponse.class); try { } catch (JSONException e) { e.printStackTrace(); } } else if (response.code() == 202) { Log.d(TAG,"RESPONSE CODE IS "+"202 RIGHT");

Response:wrong. [User registration via android app using http post not working]

邮差的信 提交于 2019-12-25 08:14:02
问题 I was able to successfully make login work. Now, I am stuck up with registration. Response is wrong. public class Register extends Activity implements OnClickListener{ private String mTitle = "Write.My.Action"; private static final String LOGTAG = "tag"; public EditText fullname, email, password; private Button register; private ProgressDialog mDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.register);

Android: Check internet connection - returns true (incorrectly)

别来无恙 提交于 2019-12-24 13:03:32
问题 To check for internet connectivity, i am using this code: public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); //return netInfo != null && netInfo.isConnectedOrConnecting(); return netInfo != null && netInfo.isAvailable() && netInfo.isConnected(); } This is the most commonly used code i found everywhere - however it is not working reliably. This is returning true, although i

How to set an exclusion list on a programmatically configured proxy on KitKat?

泄露秘密 提交于 2019-12-24 11:50:15
问题 I am using this code to setup a proxy for my WebView on Android and it is working well. I have modified the code to use an exclusion list. On devices using the android.net.ProxyProperties I am passing an exclusion list like ".google.com,.bing.com" and on devices using the System properties I am passing " .google.com| .bing.com". It is all working fine on ICS, and Lollipop but I can not get it to work on KitKat. I don't have 4.2/4.3 devices to test on but I'll try it on an emulator later,

Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`

泄露秘密 提交于 2019-12-24 02:39:11
问题 When I run this piece of code on Android 2.3.6, it works fine. On 4.0 I get a StrictMode exception. From some questions on SO, seems like you cant do network operations on the UI thread. But I am not doing any UI operation on the UI thread. I am calling doBackground directly and not execute, since I need to check the return value of the doBackground. I guess the below should have worked. What am I missing here ? handler.postDelayed(new Runnable() { @Override public void run() { God

How to check Wi-Fi connection (SSID) when connected to MOBILE at the same time on Android

醉酒当歌 提交于 2019-12-24 00:13:52
问题 I am having some strange issues when I want to verify, whether an Android device is connected to a specific Wi-Fi (identified by SSID) AND it has a MOBILE data network active at the same time. It is also likely that my issue is connected to Android 9 (SDK 28), as I did not get any complaints from users with previous Android versions. So here is what I have: This is my main method, that should tell me whether the device is currently connected to it's target Wi-Fi: public boolean

Cannot connect to native local socket on android 5.1

你离开我真会死。 提交于 2019-12-23 16:13:16
问题 I have commad-line tool, which sends broadcast and wait result. Server code (error handling omitted): int makeAddr(const char* name, struct sockaddr_un* pAddr, socklen_t* pSockLen) { int nameLen = strlen(name); pAddr->sun_path[0] = '\0'; strcpy(pAddr->sun_path+1, name); pAddr->sun_family = AF_LOCAL; *pSockLen = 1 + nameLen + offsetof(struct sockaddr_un, sun_path); return 0; } int main(int argc, char* argv[]) { //... // Create socket in abstract namespace struct sockaddr_un sockAddr = {0};

How to determine the network unavailability in android

旧城冷巷雨未停 提交于 2019-12-23 05:25:58
问题 I want to show alert that connection not available in my android application. I am calling some rest request in my application. To check this network unavailability scenario I manually disconnect my wifi in my laptop (I am testing in simulator) . Code where I call service is here resp = client.execute(httpPostRequest); and here I am catching exception catch (IllegalStateException e) { //assertTrue(e.getLocalizedMessage(), false); e.printStackTrace(); } catch (ClientProtocolException e) { /

Notify Activity of Network Change - Android

点点圈 提交于 2019-12-22 11:34:21
问题 I have an activity which needs to perform an operation once a connection to a network has been established. I tried implementing the Observer pattern but am getting a NullPointerException when I try to register the Observer activity to the subject. Any thoughts? NetworkStatus public class NetworkStatus implements NetworkStatusSubject, Runnable { List<NetworkObserver> observerList; Context context; public NetworkStatus(Context context) { this.context = context; } public static boolean