Skip to content

Instantly share code, notes, and snippets.

@prcaen
prcaen / MyActivity.java
Created January 8, 2014 09:11
The Android ActionBar Tips
// How make the ActionBar title clickable on Android under API 11 (1/2)
private static final boolean API_LEVEL_UNDER_11 = android.os.Build.VERSION.SDK_INT < 11;
private boolean navigationDrawerEnabled = true; // Useful if your app need navigation drawer
@Override
protected void onCreate(Bundle savedInstanceState) {
if (API_LEVEL_UNDER_11) {
getSupportActionBar().setCustomView(R.layout.partial_actionbar);
getSupportActionBar().setDisplayShowCustomEnabled(true);
public class NetworkLogUtility {
public static void logFailure(Call call, Throwable throwable){
if(call != null){
if (call.isCanceled())
Timber.e("Request was cancelled");
Request request = call.request();
if(request != null){
HttpUrl httpUrl = request.url();
@rivol
rivol / Util.java
Last active November 29, 2017 06:54
get retrofit error response's body
package com.gateme3.app.util;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;
import com.gateme3.app.db.PurchasedItem;
import com.gateme3.app.db.Venue;
import java.io.ByteArrayOutputStream;
@koral--
koral-- / strings.xml
Created January 14, 2018 18:13
XML entity in strings.xml
<!DOCTYPE resources [
<!ENTITY foo "Foo">
]>
<resources>
<string name="app_name">&foo;</string>
<string name="busy_warning">Sorry, &foo; is working hard, please try again in a moment.</string>
<string name="trademark">&foo; is a registerd trademark, all rights reserved.</string>
</resources>
@TouchBoarder
TouchBoarder / MainActivity.java
Created April 9, 2016 12:15 — forked from lisawray/MainActivity.java
Vector drawables from XML with the Android support library 23.3.0
package com.xwray.vectorbinding;
import android.databinding.BindingAdapter;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
@sultaniman
sultaniman / LocationService
Last active September 4, 2020 20:30
Android simple location service
package com.my.package.services;
import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
@mannodermaus
mannodermaus / LoganSquareConverter.java
Last active September 16, 2021 12:28
LoganSquare Retrofit Converter
package retrofit.converter;
import com.bluelinelabs.logansquare.LoganSquare;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import retrofit.converter.ConversionException;
import retrofit.converter.Converter;
@dmytrodanylyk
dmytrodanylyk / description.md
Last active June 20, 2022 15:00
Where this dependency comes from?

Did you ever have android build failed​ issue because of dependency resolution?

… or you were curious where all these old rxjava dependencies come from?

You can pretty easy track the module causing issues via following gradle command.

gradlew :root-module:dependencyInsight \
--configuration debugRuntimeClasspath \ // or debugCompileClasspath
--dependency io.reactivex:rxjava:1.1.0 &gt; dependencies.txt // saves result to 'dependencies.txt' file
@JakeWharton
JakeWharton / OkHttpStack.java
Created May 21, 2013 01:14
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: