android-networking

Check network connectivity android

你。 提交于 2019-12-08 05:57:34
问题 I am new using Service in Android and I am quite confused. I have and Activity and I want to check for all the time that the network connection is up (wifi or 3g). I implemented a simple Service and a BroadcastReveiver . here the code of the Service public class NetworkCheck extends IntentService { private final String CONNECTION = "connection"; public NetworkCheck(String name) { super(name); } @Override protected void onHandleIntent(Intent workIntent) { ConnectivityManager conMgr =

NetworkAvailability check returns false yet the phone is online

风流意气都作罢 提交于 2019-12-08 05:38:22
问题 I have am having some issues with getting consistent results when checking if the network is available or not. I use this code snippet inside a class AppPreferences to check the availability of a network. /** * @return the networkAvailable */ public boolean isNetworkAvailable() { connectionManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); networkAvailable = connectionManager.getActiveNetworkInfo() != null && connectionManager.getActiveNetworkInfo()

HttpUrlConnection request error (Missing Internet permission when the permission is enabled)

空扰寡人 提交于 2019-12-08 03:27:58
问题 I'm having the following error on a few of my users: Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?) at java.net.InetAddress.lookupHostByName(InetAddress.java:418) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getAllByName(InetAddress.java:214) at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216) at com

Sync device data with web-server

大憨熊 提交于 2019-12-08 02:48:09
问题 I have data in my application which must be updated on the server on the basis of network availability. I store this data on a local database on android using sqlite. Currently the idea is: Data should be inserted on the local sqlite database A service should be waiting as soon as the data is inserted it checks the network availability and send it to the server and wait for success response. If the response true is received from the server it should update the sync status of that sqlite row

Is there a way to make an android device answer to icmp pings addressed to the broadcast address?

烈酒焚心 提交于 2019-12-08 01:26:43
问题 I would like to programatically make my device answer to broadcast pings (i.e pinging 192.178.1.255) while connected to a wifi network. Is there a way i can do that ? Maybe a listener that will ping back, or a flag to set somewhere? Thanks. 回答1: Is there a way i can do that ? In short: Yes. But it will take some good effort to integrate the necessary components. The key problem is that you need to listen for ICMP network packets. Such functionality is not accessible from Java and would

How to retry a consumed Observable?

喜你入骨 提交于 2019-12-08 00:07:02
问题 I am trying to re-execute a defined observable that failed. Using Retrofit2 and RxJava2 together i want to retry a specific request with its subscription and behavior when clicking a button. is that possible? service.excecuteLoginService(url, tokenModel, RetrofitManager.apiKey) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(....) 回答1: An option is to create Publisher, which emission is controlled by your button. final PublishSubject<Object>

HttpUrlConnection request error (Missing Internet permission when the permission is enabled)

此生再无相见时 提交于 2019-12-07 15:49:27
I'm having the following error on a few of my users: Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?) at java.net.InetAddress.lookupHostByName(InetAddress.java:418) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getAllByName(InetAddress.java:214) at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122) at com.android.okhttp.internal

Android VOIP applications behavior in Doze mode

懵懂的女人 提交于 2019-12-07 02:52:06
问题 I'm working on legacy VOIP application on Android. It doesn't use Google Cloud Messaging technology right now, but just keeping its own TCP connection forever. Recently Google has introduced its Android M preview release with Doze mode So the question: is there any workaround how the app can receive incoming calls/messages in Doze mode without redesigning the whole system to use GCM? 回答1: You may use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to ask the user permission to be ignored by

Upload and Download rate profiling in Android [closed]

 ̄綄美尐妖づ 提交于 2019-12-07 01:46:28
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I'm trying to develop an Android app to measure the upload and download speed of my network, which probably I would need to run and profile it every 2 seconds or so. SpeedTest.net app is an ideal app working similarly, however, it is not open-source. Moreover, I would need it to

How to get the name of operator which is connected to internet in dual sim android phone?

穿精又带淫゛_ 提交于 2019-12-07 01:40:33
问题 I have made a network monitor app. Here I have successfully implemented all the things. I have the dual sim android phone. I know how to get the name of operator. But I want to that which sim is connected to internet? I have used this code, only to show user that the device is connected through mobile data. I want to be more specific that the device is currently using which operator's internet. public static String isInternetConnected (Context ctx) { ConnectivityManager connectivityMgr =