How to save a request and send it in an Android application

in my application I am trying to send some data to the network. but the application becomes slow or crashes when the network is unavailable.

How to save the request later and send it after re-covering the network?

how to do it.........

0
android networking
source share
2 answers

@Aleadam is right, you should publish your details later as soon as your Internet is connected, however you can check your intention to connect using this method.

public boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; } 

but for this method you will need to import some Android libraries these

 import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; 

Hope this helps.

0
source share

If the transmission public final boolean postDelayed(Runnable r, long delayMillis) you can use public final boolean postDelayed(Runnable r, long delayMillis) to retry at the specified time. You will need to configure the Runnable class and submit the overriding method to execute the data ().

http://developer.android.com/reference/android/os/Handler.html

http://developer.android.com/reference/java/lang/Runnable.html

+1
source share

All Articles