Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Last active July 19, 2017 15:20
Show Gist options
  • Save t-kashima/f2f3be8aeedbf348c3b2172b8d36cff8 to your computer and use it in GitHub Desktop.
Save t-kashima/f2f3be8aeedbf348c3b2172b8d36cff8 to your computer and use it in GitHub Desktop.
Send transited activity to Fabric
...
override fun onResume() {
super.onResume()
saveTransitionScreenName()
val transitionScreenName = getTransitionScreenName()
Timber.d("ScreenName: " + transitionScreenName)
Crashlytics.setString("ScreenName", transitionScreenName)
}
private fun saveTransitionScreenName() {
val sp = getSharedPreferences("preferences", Context.MODE_PRIVATE)
val edit = sp.edit()
val screens = sp.getString("screens", "").split(" > ").takeLast(4).toMutableList()
screens.add(javaClass.simpleName)
val screenName = screens.joinToString(" > ")
edit.putString("screens", screenName)
edit.apply()
}
private fun getTransitionScreenName(): String {
val sp = getSharedPreferences("preferences", Context.MODE_PRIVATE)
return sp.getString("screens", "")
}
...
@t-kashima
Copy link
Author

2017-07-20 0 19 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment