Post is pinned.
Transitioning to StackOverflow for questions and answers.

This community has grown beyond anything we expected when it was initially created. We are happy to see so many people using and enjoying our open source libraries. It makes us even more happy to see users of these projects come together to help each other resolve problems. One thing we have noticed in moderating this community is that it is not the best medium for asking questions and archiving their solutions.

To ensure your questions and their answers are appropriately archived and searchable we are transitioning them to StackOverflow. A website that needs no introduction to a modern-day programmer, StackOverflow is a much better platform for community-driven problem resolution.

Individual tags for our respective projects have been set up and will be maintained by the individual project owners. Projects with websites have been updated to link to their respective tag directly.

StackOverflow offers some unique features which Google+ does not provide that may be of interest to you. The most notable is the ability to subscribe to tags which will email digests at 15 minute, 3 hour, or daily intervals. You can see my subscriptions[1] for an example.

This community will continue to exist for discussion which doesn't belong on StackOverflow or on a project's GitHub issues. We will be politely pushing any questions that are asked towards StackOverflow.

Thanks for all your support thus far and we look forward to seeing you all on StackOverflow!


[1]: http://stackexchange.com/users/44914?tab=subscriptions

Post has attachment

I use Picasso ant it works very well. I created a custom interceptor and now doesn't load image in offline.
It works online... but when close app and re-open in Airplace mode Picasso doens't load image.
If i load image without interceptor all works very well.

Here my code:


@Provides
@Singleton
Picasso providePicasso(final Environment environment) {


Cache cache = new Cache( new File(context.getExternalCacheDir()+ "/images"),
80 * 1024 * 1024);
OkHttpClient defaultHttpClient = new OkHttpClient.Builder()
.addNetworkInterceptor(
new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request request = chain.request().newBuilder().
addHeader("X-CLIENT",environment.getClient()).
addHeader("X-SID",CamApplicationImpl.appComponent.environment().getSessionId()).
addHeader("X-TOKEN",CamApplicationImpl.appComponent.environment().getToken()).build();
return chain.proceed(request);
}
}).cache(cache).build();
Picasso picasso=new Picasso.Builder(context).downloader(new OkHttp3Downloader(defaultHttpClient)).build();
return picasso;
}

Post has shared content
Hello guys I am new for retrofit and I am using it and I have implemented in activity directly not inside thread and when I am starting then it taking lot of time and blocking User Interface also and after getting response and when I hit again same by restarting activity It wait unlimited time. It is being stuck on same request. My code is here
I have an activity and having three fragment and using pager so firstly I am hitting web-service inside activity and using call back updating my recycler view adapter

retrofit = new Retrofit.Builder().baseUrl(baseURL).addConverterFactory(GsonConverterFactory.create()).build();
app = retrofit.create(ApiInterface.class);
Call<List<Pojo>> listCall = app.getDetails();
sb = new StringBuffer(URL);
sb.append(",");

listCall.enqueue(new Callback<List<Pojo>>() {
@Override
public void onResponse(Response<List<Pojo>> response, Retrofit retrofit) {

final ArrayList<Pojo> list = (ArrayList<Pojo>) response.body();
for (int i = 0; i < list.size(); i++) {
if (i == 0)
sb.append("" + list.get(i).getImei());
else
sb.append(";" + list.get(i).getImei());

}
Ion.with(MainActivity.this).load(sb.toString())
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null)
Toast.makeText(getApplicationContext(), "Error : " + e.toString(), Toast.LENGTH_SHORT).show();
else {
try {
list_pojo = new ArrayList<>();
address_description = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
JsonObject jsonObject = result.getAsJsonObject(list.get(i).getImei().toString());
list_pojo.add(new Imei_Pogo(jsonObject.get("dt_server").getAsString(), jsonObject.get("dt_tracker").getAsString(), jsonObject.get("lat").getAsDouble(), jsonObject.get("lng").getAsDouble(), jsonObject.get("altitude").getAsString(), jsonObject.get("angle").getAsString(), jsonObject.get("speed").getAsInt()));
geocoder = new Geocoder(MainActivity.this, Locale.getDefault());
addresses = geocoder.getFromLocation( jsonObject.get("lat").getAsDouble(), jsonObject.get("lng").getAsDouble(), 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
address_description.add(address + "," + city + "," + state + "," + country + "-" + postalCode);
}
// new MyDataBase(getApplicationContext()).insertData(list,list_pojo,address_description);
callback.updateUI(list, list_pojo,address_description);

dialog.dismiss();
} catch (Exception g) {
g.printStackTrace();
}
finally {
if(dialog.isShowing())
dialog.dismiss();
}
}
}
});
}

@Override
public void onFailure(Throwable t) {
Toast.makeText(MainActivity.this, "failed", Toast.LENGTH_SHORT).show();

}
});
}

Post has attachment
Hi everyone,
Would anyone be able to help me with my @Streaming issue on Stackoverflow?

Thanks

Post has attachment
Hey everyone! Just so you know, there's a way to use Spoon on Android cloud devices. We've made a tutorial on this. This might be of interest for you ;)

Hi, Guys, Pls let me know is it possible to fetch 30K records in android using retrofit considering with less amount of time in milli seconds (<1000 ms)

Hello Guys, Retrofit users,
Please, I have a problem caching with Retrofit.
I have a server which sends the following response

Server: Apache
X-Powered-By: PHP/5.5.38
App-Version: {"id":3,"current_version":"0.2","required":"true","build_date":"17-6-2016"}
Cache-Control: public,max-age=300,only-if-cached, max-stale=86400
Upgrade: h2
Connection: Upgrade
Transfer-Encoding: chunked
Content-Type: application/json

with Volley the response gets cached properly but with Retrofit it never does. I have setup the retrofit client like this

Cache cache = new Cache(cacheDir, cacheSize);
httpClient=new OkHttpClient();
httpClient.setCache(cache);
httpClient.networkInterceptors().clear();
httpClient.networkInterceptors().add(new NetworkInterceptor());
restService=new Retrofit.Builder()
.baseUrl(HOST_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient)
.build()
.create(RestService.class);

and the network interceptor

ublic class NetworkInterceptor implements Interceptor {
public static final String DEBUG_TAG = NetworkInterceptor.class.getSimpleName();

@Override
public Response intercept(Chain chain) throws IOException {
Request request=chain.request();
User user=UserHandler.getUser();
if (user!=null&&user.getToken()!=null){
Log.d(DEBUG_TAG,"Authorization: "+user.getToken());
request=request.newBuilder().addHeader("Authorization",user.getToken())
.method(request.method(),request.body())
.build();
}
Response response = chain.proceed(request);
Log.d(DEBUG_TAG, "Cache-Control: " + response.cacheControl());
return response;
}
}


The cache folder is created but the only folder there is the "journal" folder. Please what do I need to change or add in the server or android client? I'll appreciate any help

Hi guys i use retrofit in my project, to load pictures from server into my app. When I try load it synchronous, my main thread freeze. Can you tell me about method execute in interface call ?

Hi! Is there any out-of-box way to use idling resource of Espresso for OkHTTP library?
Wait while more posts are being loaded