-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easy to get the latest activity #2
Comments
Hello :) You said that you don't get how I am doing it. Well my solution is to write your own runner and extend Application object used by your app under test.
So now my app will use
And with that you can do static imports of What do you think about memory leak threat in both cases? |
Didn't know about that solution, so thanks for the share ;) you should put it in the docs! :) Between the two solutions I don't know which one is more is more reliable, I would have to go deeper into it to find out. The one you proposed is a bit too verbose, though. Nonetheless, I don't mind so much which solution gets picked, what I do think is important is to make it easy for the user to get the current activity. So whatever solution we go with, it should be wrapped in a function and exposed as an utility function (or passed as an argument, if it's commonly used). Memory leaks wise it looks to me that both solution are the same, the |
Did your solution work for you? For me it doesn't seems to block anything and I receive massive amount of null pointers from getCurrentActivity() in Instructions. |
It did, but I made a slight alteration.
|
First, thanks for this tool! IdlingResource is a total mess.
Now to business, from the documentation I was not able to understand how to get the latest activity.
However, I found a different way, which follows:
Example on how to use:
getCurrentActivitySafe()
has to be called insteadgetCurrentActivity()
becausecheckCondition
can run outside of the UI thread, causing an error.My suggestion is to make
getCurrentActivitySafe()
an utility function, or to rename it togetCurrentActivity()
and make it a method ofInstruction
.Another alternative is to make
checkCondition
a method that receives the current activity as an argument, like thischeckCondition(Activity currentActivity)
The text was updated successfully, but these errors were encountered: