I have been playing around with Android app development, particularly on how to retain UI values after configuration changes and minimizing the app to launch a different one. To retain values after configuration changes, I use ViewModels. And to retain values after minimizing the app, the following is supposed to do the trick: But in […]
programming
DataBinderMapperImpl Error: cannot find symbol (DataBinding) //Android Kotlin Dev Diary
Today I encountered the following error as I was building an Android app: Turns out, there’s an error in the related XML file, activity_main.xml! 😂 For other possible solutions, this StackOverflower answer may help: android: data binding error: cannot find symbol class
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:
1 2 3 4 |
<service android:name=".service.SyncService" android:exported="true" android:process=":sync"> |
But […]
Android app dev: Intent extras set in onBackPressed() misssing when back to onActivityResult()
It’s funny how we spent about an hour trying to figure out why the Intent extras that we’re setting are not being sent back to onActivityResult(). If we only knew that the solution was as simple as moving one line of code. The call to super.onBackPressed() should be placed after setting Intent extras and after […]
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:
1 |
compile 'org.apache.commons:commons-lang3:3.4' |
Hope this saves somebody […]
Something to avoid when using Android RecyclerView
When using Android’s RecyclerView, don’t use the same inflated XML layout file for items you intend to shuffle on the fly! Their contents will overlap. -CK
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:
1 2 3 4 5 6 7 8 9 |
myRecyclerView.post(new Runnable() { @Override public void run() { myArrayList.remove(position); myArrayList.add(something); recyclerViewMainScreenHeader.getAdapter().<code>notifyItemChanged</code>(); } }); |
Setup/update Ruby on OS X El Capitan 10.11.5
I need to learn Ruby on Rails for my new job. I’m a little thrilled about this chance to learn a new language, and I’m trying to get started with it on my Macbook which runs OS X El Capitan 10.11.5. I already have Ruby here, I don’t remember if pre-installed though. It’s out of […]
Simple SMS Reader app in Android using BroadcastReceiver class
Before I began coding Android apps, I was amazed how verification processes go like this: The Android app tells you they’ll send you an SMS containing verification code, and that you need to enter such code into a text field on the Android app. But when you receive the SMS, the verification code appears on […]
Android app dev: Add ActionBar to Preference Activity
When I converted an activity into PreferenceActivity, I noticed that its ActionBar disappeared. I’ll show you how I brought the ActionBar back to my PreferenceActivity. In this guide I will assume that the name of the file that contains your is SettingsActivity.java, and that the view assigned to your SettingsActivity.java is named . First, create […]