Skip to main content

How to retry HTTP requests with OkHttp/Retrofit?

I need to retry some of my requests so I searched for a simple way to that bu I can't find it.

I  find a stackoverflow question[0] about it but answer suggests a complicated solution.

So if you want to retry a request you can find my answer useful.  http://stackoverflow.com/a/31733634/1577792


[0] - http://stackoverflow.com/q/24562716/1577792

Comments

Popular posts from this blog

Using Accelerometer when Screen Off

Introduction Android Phones have a lot of built-in sensor such as gyro, proximity and accelerometer. Using Accelerometer in Android is a known thing. For listening sensors, class or service needs a SensorEventListener implementation. An Activity is only exists when you are seeing it. When phone enters standby mode, activity which was recently active frozen and restored whenever needed. While this frozen time, activity doesn’t run. Because of that it doesn’t need sensor updates. And Android stop to listen some sensors for power management. Services have this condition like classes (activity). In contrast to class, a service run every time, even when phone is in standby mode. Therefore Services needs sensor updates for some situations. But android stop to listen some sensor(accelerometer) in some different phones. There is a solution for that. This is not an exact solution but it work with a lot of phones. With a BroadcastReceiver listen   Intent. ACTION_SCREEN_O

How to change position of MyLocationButton on new Map API v2? Explained

When an app use map and design some layout on this map (TextView, Button or image), developer needs to change position of default buttons of map view. (MyLocationButton, ZoomControl or compass...) As far as i know, there are two possible way for changing position of myLocationButton's position. 1- * - Disable it     * - Create new button programmatically     * - Add animateCamera(toCurrentLocation) to onClickListener of this button     * - And place it wherever you want But if you don't want to write all that there is a hack for that. 2 - * - findViewById() of hardcoded button with; ZoomControl id = 0x1 MyLocation button id = 0x2      * - And do whatever you want: // Find map fragment SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); // Find myLocationButton view View myLocationButton = mapFragment.getView().findViewById(0x2); if (myLocationButton != null && myLocationButton.get

How to set alarm to show a notification at future date with AlarmManager?

Lets assume you want to do a job a future time or show a notification at a selected time. AlarmManager can help to send an intent in future time. First we need to select date, Lets create a date in 2050, Calendar calendar = Calendar. getInstance () ; calendar.set(Calendar. YEAR , 2050 ) ; Date date = calendar.getTime() ; For showing notification we need a service. public class AlarmReceiver extends Service { public AlarmReceiver() { } @Override public IBinder onBind (Intent intent) { } } Add service to Manifest.xml <service android :name= "com.kozaxinan.example.alarm.AlarmReceiver" android :enabled= "true" android :exported= "true" > </service> We will modify AlarmReceiver for sending notification. But first we need to register a alarm. AlarmManager alarmManager = (AlarmManager) getSystemService( ALARM_SERVICE ) ; Intent intent = new Intent( this, AlarmReceiver. class ) ; intent.putExtra( &q