When internet connection is on I want to send location parameter to server, and when internet off I want to save location parameter in realm database and after sometime when internet again on I want to send current location parameter to server and also send location parameter which saved in realm database to server which approach should I used.
Asked
Active
Viewed 47 times
-2
-
you can use broadcast receiver for internet connectivity change for further reference you can go to this [link](https://stackoverflow.com/a/26114247/5308778) – yashkal Nov 30 '17 at 05:54
-
1Please explain first what you have tried and where you stuck. – Samir Bhatt Nov 30 '17 at 05:56
-
2Where is your code? What you did? You want community to write your application code? – Abhishek Nov 30 '17 at 05:58
-
just listen to internet connection state changes. – Vladyslav Matviienko Nov 30 '17 at 07:11
2 Answers
0
You can create a database and store those values there. Now after sending those value you must remove them from you database.
Now , create a broadcast class that always check the network status.When network comes it will check that db and send them on server. You can code it accordingly.
public class NetworkStatusChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
boolean status = Utility.isInternetAvailable(context);
if (!status)
{
Toast.makeText(context, "Network Error !", Toast.LENGTH_SHORT).show();
}
}
}
Put this in manifest.
<receiver
android:name="NetworkStatusChangeReceiver"
android:label="NetworkStatusChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
This might be helpful !!!!!

Dilip
- 2,622
- 1
- 20
- 27
0
Follow this link to check internet connection check network connection
and if internet connection not found then store it to local database.

Aj 27
- 2,316
- 21
- 29
-
-
@H.Brooks I already answered this question on this link, I don't want to duplicate answers to the same questions in different places. – Aj 27 Nov 30 '17 at 06:31
-