0

While working with app User opening different activities. To track that the standard way is just put in onCreate the trigger. But in this case I need to manage all triggers individually in each activity. But is it possible to implement this trigger somewhere in the app level where all opening of the activities could be controlled from one place? I need something like a pattern might be or logic to track all interactions with my activities from on place

Bo Z
  • 2,359
  • 1
  • 13
  • 31
  • What do you mean by "all opening of the activities"? Do you want a place to see all the different available exit points from screen 1 to screen 2/3/4 for example? – Tamir Abutbul Jul 19 '19 at 18:55
  • @TamirAbutbul user open activity 1 activity 2 slide fragment 1 slide fragment 2. So total there are 4 actions which user done. He got 4 total screens. So i want not to manage them separate i want to count just interactions and trigger when the number is 100 for example – Bo Z Jul 19 '19 at 19:01
  • https://developer.android.com/reference/android/arch/lifecycle/Lifecycle seems to do the thing – Rawnald Gregory Erickson Jul 19 '19 at 19:04
  • @BorisRuzanov Check my answer and tell me if I understood your question properly. – Tamir Abutbul Jul 19 '19 at 19:07

1 Answers1

0

I think that the closest thing will be navigation component, it's basically a graph that shows and let you control different destinations that are connected via actions.

It will look like this:

enter image description here

With this, you can control interactions and trigger when it comes to navigation like you wrote in your comment.

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
  • Thank you very much for time. But I am looking something kind of an advice how it is better to implement this kind of logic. I will edit my question – Bo Z Jul 19 '19 at 19:12
  • ***how it is better to implement this kind of logic.*** Maybe you meant - how can you write a code that takes the user to different screens according to condition? is that it? – Tamir Abutbul Jul 19 '19 at 19:14
  • no there is not a problem to write a code. I just need to understand where i can put trigger to see all activity flows of my app. I was trying to use onCreate in App class but oncreate execute only once – Bo Z Jul 19 '19 at 19:29
  • Why not use Logs? for example, use log with TAG named "flowText" and custom message, in your app play with your screens - move between them and after you have done just search "flowText" in the LogCat to see all the message from your logs, this will give one place (the logcat) to see your flow. – Tamir Abutbul Jul 19 '19 at 19:34
  • i know. But the point of that to show dialog. So in prefs with each action the counter suppose to make +1 and when it is 100 it suppose to show dialog. I know how to make the logic with each screen but might be another solution to make less and flexible code – Bo Z Jul 19 '19 at 19:39
  • If that's the case I think you could save and update an integer like [in this thread](https://stackoverflow.com/questions/3624280/how-to-use-sharedpreferences-in-android-to-store-fetch-and-edit-values) using `SharedPreferences `. Before every update of that integer, you can update you dialogs UI or check if it's on 100 and only after pop the dialog – Tamir Abutbul Jul 19 '19 at 19:43
  • Yes it is. But the question is that I dont want to check it in each separate onCreate. Want to check it in one place. – Bo Z Jul 19 '19 at 19:47
  • I don't think it possible. I think that you will have to make this check every time you move a screen. – Tamir Abutbul Jul 19 '19 at 19:50
  • Thats what I am thinking if there in Android something which triggers when we are moving from one screen to another. So I can use that trigger for my own implementation. But cant find – Bo Z Jul 19 '19 at 19:53