Welcome to the sixth round of tips in our ongoing series, " Android Development Tidbits." We hope they help you learn something new about development that you didn’t know before.
Tidbit One On the “debugging” pane in Android Studio, there’s a button that looks like two overlaid breakpoints. Clicking this button takes you to a window that lists all currently set breakpoints. This is great for when you get “ghost” breakpoints - where it’s breaking somewhere even though you removed the breakpoint. (Bonus: You can set ‘field’ breakpoints that trigger whenever that field is set.) -Tidbit Contributor, Frank Doyle
AppCompatDialog.setStyle(STYLE_NO_TITLE, ...) doesn’t actually work, it will throw an exception. Instead, if you need a dialog with no title, create a theme without a title and pass that theme into the dialog’s constructor.
-Tidbit Contributor, Evan Tatarka
Tidbit Three When opening the camera app on Android 6.0+ with an intent, you need to request Camera permissions to actually get back a result. -Tidbit Contributor, Evan Halley
Tidbit Four To fade out tab icons, use
onPageScrolled to get the offset and set the alpha based on that.
-Tidbit Contributor, Hyun-Woo Park
The Facebook SDK maintains an Access token - so if you’re using Parse while trying to link a Facebook account and it fails (because that account is already linked to another user), the SDK will keep that access token, attempt to login with a different Facebook user, and fail because it’s a bad access token. Instead, set the Facebook Access token to null before restarting the FB auth flow, and remember to clear
WebView cookies too. (Also, if you’re using Parse, you might want to start making a backup plan as they’re officially shutting down.)
-Tidbit Contributor, Fabian Reddig
Tidbit Six You can store Android Studio settings in a git repo and have Studio sync those settings to a remote, or have a remote sync to local, or even have the two merge. -Tidbit Contributor, Eric Richardson
Tidbit Seven When retrieving data from an HTTP endpoint, you can use the ‘Content-Encoding’ header to detect the content encoding of the incoming data. This is useful if you are downloading data from a server that supports GZip, Deflate, etc. https://gist.github.com/emuneee/c3a948fb9b227e59716b -Tidbit Contributor, Evan Halley