Android: SharedPreferences not accessible from SyncAdapter

When I was trying to access a SharedPreferences value from my Android app’s SyncAdapter, I kept on receiving an old value that was saved to the key. Quick solution to inaccessible SharedPreferences from SyncAdapter A quick solution (which may be a short-term one) I tried was to remove android:process=”:sync” from the following code:

But […]

Read More

Android app dev: Missing import org.apache.commons.lang3.text.WordUtils;

I use a few instances of WordUtils.capitalizeFully() on an Android app that I’ve been working on. And there are times when the import org.apache.commons.lang3.text.WordUtils; breaks, sometimes after merging with some of my git branches. To fix this, what I do is open app/build.gradle and add the following line under dependencies:

Hope this saves somebody […]

Read More

Android RecyclerView notifyItemChanged() IllegalStateException “Cannot call this method while RecyclerView is computing a layout or scrolling”

If your Android app is crashing with error IllegalStateException “Cannot call this method while RecyclerView is computing a layout or scrolling”, you may try placing your notifyitemchanged inside a Runnable. Assuming you have a call to notifyItemChanged() inside onBindViewHolder() that is making your app crash with IllegalStateException, you may try something like this:

Read More

Laravel 5: activate API token guard and print “Unauthorized” instead of login redirect

In Laravel 5, I wrap my API routes in a route group like this:

Notice that I use auth:api and throttle on my middleware array. auth:api turns on the auth middleware with API token as guard, while throttle activates rate limiter for APIs. To get started with API token authentication, you may read […]

Read More