robotium testing wait time between each clicks - android

in robotium testing, is it possible to set a wait time between clicks? For example, I have 2 buttons(A & B). I want robotium to click on button A and then 20 seconds later click on button B.

u can use this code its working fine
solo.clickOnButton(0);
solo.sleep(20000); // 20 seconds
solo.clickOnButton(0);

If the purpose is to wait for a fixed amount of time then use solo.sleep(20000). If you want to wait for a condition before moving on you can use the waitFor methods.

Related

Android onCreate flow

I'm new to android development and working these days on my first app.
In my activity, in the onCreate function I make 2 function calls , each of the 2 functions has different OnClickListener for different buttons.
Everything works fine , my question is why?
I mean how does it possible that both of the listeners functions "work" on the same time does the app runs in a parallel way? In my head I thought that once the app reach an OnclickListener it will just stop and wait for a buttonClick event but I can see that I can click on button1 and something happens and then I click on Button2 and something else happens (as it should).
I just want an explaination, in general, about the way (flow) the app work/ handles functions of listeners and click events.
Thank you,
Noam
I totally understand what you mean.
button.setOnClickListener(this) means this button just tells the activity that it has a click event. The app won't pause or wait until the button event is executed.
when different widget is clicked, it's own click event will be executed.

How to start Login Activity if user wasn't active for 5 minutes:

I need to start the log in Activity if the user wasn't active for 5 minutes in the application
,without considering from what activity he left the application. (by not active for 5 minutes I mean that the user didn't commit any action to the server side)
I have a Date variable inside my Application class:
private Date timeOfLogin;
that's is saved when the user commits log in, in some point of usage the user can get a phone call or
a mail and will leave the application. now this can happen on any screen of the application. And now when he turns on the application again /return to it after finishing his phone call I need to show the log in screen again and not his last activity if 5 or more minutes have passed.
How can it be done? do I have to override every onResume of each activity I have in the application and start the log in Activity if the difference between the timeOfLogin and current date is bigger then 5 minutes? or is there a better way to do that?
Any help would be appreciated.
Thanks.
Have an activity that all of your other activities extend and put the logic in that activity's onResume. (You'll probably find this practice to be useful in a lot of other ways too)
Create a CountDownTimer with 5 minute count down in your ResponseHandler class in the onFinish() show the login dialog. If there is any response cancel the timer and start again.

User stuck in loading Webview. Where to set timeout, and how to allow user to navigate out of webview?

I have a Webview which during slow network connections takes a long time to load. The problem beyond that is that the user is essentially stuck on the Webview. Clicking on the back button does NOT close out the Webview activity, at least not on 2.2 devices. What can I do to allow users to navigate back from the Webview if its taking too long?
Thanks
You might need to dismiss the progress dialog and even you can destroy( by setting finish() ) the present webview activity by setting the timer. You can set whatever time you need. For example, if it takes more than 5 minutes, then you can set the time limit to 5 minutes and dismiss the dialog and destroy the activity. You can also follow as in this thread, if you want . Hope my answer helps you.

Stop watch app inventor

I'm new user of App inventor. I need small stopwatch. Basic function:
- set time ex. 25 min (if time=0;alarm=true)
- start time
- reset time (if you want reset time you will see the comfir box (yes or no)
Can anybody show me what block I must use to create it ?. Sorry for my English.
Here is a link to a discussed about this in the App Inventor Coffee Shop.
https://groups.google.com/forum/?fromgroups#!topic/appinventor/qrhfCSv4US0
This block will need a label, and a timer.
You can choose to make it in seconds or milliseconds by changing the clock functions.
Here is an example. The user enters the duration into the minute and second textboxes. Then they press the button. The timer interval is set to the duration converted to milliseconds. Then the timer is enabled. After the duration is up, Clock1.timer fires. The notifier shows an alert that the timer finished and the timer turns off. To reset the timer, just set Clock1.timerEnabled to true.

Android slow query

In my main activity A, I have a button, when click, it will go to another activity B. when b on create, it queries from a table which is about 200 records and appends each record as textview into a ViewFlipper.
I have few problems. First, when the button in main activity is clicked, it takes about 3-5 seconds before go to activity B everytime.
Any suggestions?
Run some traceview to see what is slow, or manually add time stamps. It depends on how the query and schemes are setup, but if the count of the table is only 200, then the should maximum take a few milli seconds.
If it is the case that you create and layout 200 TextViews in onCreate, then i would think that is the reason for why it is slow.
Run your query in a separate thread or consider using asynquery ?
I think AsyncTask or Thread are better option for getting the details. Show progressbar when doing background processing.
This example simulates your problem.
AsyncTask basic Example : AsyncTask
You need to use asyncTask to get 200 records. It runs query in background

Categories

Resources