Re: How to get instances of a default android views ?

97 views
Skip to first unread message

naveed

unread,
Jun 7, 2013, 2:40:15 AM6/7/13
to robotium-...@googlegroups.com
View myView = solo.getView(); should work, what is the problem? can you please come up with more info?

On Thursday, June 6, 2013 9:40:52 PM UTC+5, Gennadiy Ryabkin wrote:
Hello
I need to get instances of the default views like Button android.R.id.button1 and FrameLayout android.R.id.custom. I tried both solo.getView() and getActivity().findViewById(). Does anyone know how to do this ?

naveed

unread,
Jun 10, 2013, 2:46:14 AM6/10/13
to robotium-...@googlegroups.com
Oh ok, well almost same type of thread is already in discussion on  https://groups.google.com/forum/?fromgroups#!topic/robotium-developers/Oyhcq-nGX6A
the point is Robotium can't interact any view outside of the <target package> set in Manifest.xml. 

The workaround is if we can get focus of specific dialog/view it will work with Robotium. You can use following code to get focus but it works in some cases only,
private void getFocus() {
       @SuppressWarnings("rawtypes")
       Class a = YourActivity.class;
       getInstrumentation().setInTouchMode(true);
       Intent intent = new Intent(Intent.ACTION_MAIN);
       intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       intent.setClass(getInstrumentation().getTargetContext(), a);
       setActivity((Activity) getInstrumentation().startActivitySync(intent));
   }

Hope that helps,

On Friday, June 7, 2013 1:45:54 PM UTC+5, Gennadiy Ryabkin wrote:
No, no. I know how to use this stuff and do it already long. But now I need to handle android system messages like "Not responding" alert dialogs or default "Loading" progress dialogs.I google it and found that in android some defaults buttons can be invoked by specifying the following source id paths: android.R.id.button1, android.R.id.custom

четверг, 6 июня 2013 г., 19:40:52 UTC+3 пользователь Gennadiy Ryabkin написал:

naveed

unread,
Jun 11, 2013, 2:21:03 AM6/11/13
to robotium-...@googlegroups.com
Idea of the code is, it will try to get focus of your running activity in background when some dialog pops-up unexpectedly. Once you get focus the dialog will go away simple using solo.getBack() or using key events.  
 

On Monday, June 10, 2013 2:04:21 PM UTC+5, msj...@gmail.com wrote:
Hi naveed,

Is your workaround also applicable to only APKs ? What would it be like if I am using APK for my test and just wanted to handle the loading dialog ?

Thanks!
Reply all
Reply to author
Forward
0 new messages