[android-developers] Detect shaking
Hello, Is there an easy way to detect shaking of the phone? Or do I have to implement it myself by monitoring the sensors? If so, any hints on how shaking looks like from the sensor point of view? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Testing the menu
Hello, I'm trying to write an instrumentation test for checking the correct visibility of menu items according to the state of the application. Do you know how can I programatically get ahold of the visible menu items, the menu or something? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: X and y coordinates for clicks and long clicks
That gives you the x and y coordinates when there's a touch event, not an onClick, onLongClick or onContextMenuSomething. On Sun, Feb 22, 2009 at 2:55 PM, Lewis lewisandrewba...@googlemail.comwrote: This is how i found x and y coords of a click: create an ontouchlistener, override 'onTouch' and use getRawX() to get an x coord. final OnTouchListener myListener = new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { xInit = event.getRawX(); yInit= event.getRawY(); } } return false; } Hope this helps Lewis On Feb 22, 12:15 pm, J. Pablo Fernández pup...@pupeno.com wrote: It seems it's also not possible to know where exactly was the long clicked performed in a view to trigger a context menu. :S On Sat, Feb 21, 2009 at 3:41 PM, J. Pablo Fernández pup...@pupeno.com wrote: Hello, When you receive clicks and long clicks, how do you get the x and y coordinates that were clicked? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] X and y coordinates for clicks and long clicks
Hello, When you receive clicks and long clicks, how do you get the x and y coordinates that were clicked? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] How do you pass a Bundle to an activity on an instrumentation test case?
Hello, When implementing an ActivityInstrumentationTestCase, how do you start the activity with a Bundle of saved state? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How do you save the state of an activity on an ActivityUnitTestCase
Thanks. I did give ActivityInstrumentationTestCase a try but it didn't work. Now I gave it another try with a fresh look and it's partly running (the test is failing, but I believe the problem is somewhere else so if I post I'd do it as another thread). On Sat, Jan 24, 2009 at 9:19 AM, Andrew Stadler stad...@gmail.com wrote: Pablo- ActivityUnitTestCase is extremely limited in its support for operations that require interfacing with the rest of the system, because the Activity is never attached to the Activity Manager or the rest of the runtime. It may be possible to fix this particular case (so you can make this call via Instrumentation) in an update but in the meantime, you will probably find it easier to use ActivityInstrumentationTestCase - have you tried that? --Andy On Thu, Jan 22, 2009 at 12:28 AM, J. Pablo Fernández pup...@pupeno.com wrote: Hello, In an ActivityUnitTestCase I'm trying to do: Activity activity = startActivity(INSERT_INTENT, initialState, null); Bundle outState = new Bundle(); getInstrumentation().callActivityOnSaveInstanceState(activity, outState); But on the save state call I get this trace: android.util.AndroidRuntimeException: Acquiring SearchManager objects only valid in Activity Contexts. at android.app.ApplicationContext.getSearchManager(ApplicationContext.java:976) at android.app.ApplicationContext.getSystemService(ApplicationContext.java:861) at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:73) at android.app.Activity.getSystemService(Activity.java:3091) at android.app.Activity.performSaveInstanceState(Activity.java:1004) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1255) at com.blah.blah.SomeActivityTest.testLoadingAndSavingState(SomeActivityTest.java:90) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:136) at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:126) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:155) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:142) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:313) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1508) Going through the ApplicationContext source code I've found this (http://tinyurl.com/d8qsyc): private SearchManager getSearchManager() { // This is only useable in Activity Contexts if (getActivityToken() == null) { throw new AndroidRuntimeException( Acquiring SearchManager objects only valid in Activity Contexts.); } synchronized (mSync) { if (mSearchManager == null) { mSearchManager = new SearchManager(getOuterContext(), mMainThread.getHandler()); } } return mSearchManager; } It seems the problem is that the activity token is not set. But here I'm puzzled, I don't know where to go next. Any ideas on how to fix it or workaround it are appreciated. I want to test that my application is saving its state correctly. Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Should onSaveInstanceState call super?
Hello, At the beginning of my onSaveInstanceState I was calling super.onSaveInstanceState(outState) and everything was working fine. But now I wrote an instrumentation test case which basically does: Activity activity = getActivity(); getInstrumentation().callActivityOnStart(activity); getInstrumentation().callActivityOnResume(activity); Bundle outState = new Bundle(); getInstrumentation().callActivityOnSaveInstanceState(activity, outState); and I'm getting this error: Only the original thread that created a view hierarchy can touch its views. (stack trace at the bottom). So I'm wondering, what am I doing wrong here? the test or the app? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) PS: The stack trace: Error in testLoadingAndSavingState: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRoot.checkThread(ViewRoot.java:1849) at android.view.ViewRoot.invalidateChild(ViewRoot.java:468) at android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:481) at android.view.ViewGroup.invalidateChild(ViewGroup.java:2250) at android.view.View.invalidate(View.java:4095) at android.widget.TextView.invalidateCursor(TextView.java:2767) at android.widget.TextView.access$1300(TextView.java:151) at android.widget.TextView$ChangeWatcher.spanChange(TextView.java:4278) at android.widget.TextView$ChangeWatcher.onSpanAdded(TextView.java:4304) at android.text.SpannableStringInternal.sendSpanAdded(SpannableStringInternal.java:312) at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:136) at android.text.SpannableString.setSpan(SpannableString.java:46) at android.text.SpannableStringInternal.init(SpannableStringInternal.java:50) at android.text.SpannableString.init(SpannableString.java:30) at android.widget.TextView.onSaveInstanceState(TextView.java:2015) at android.view.View.dispatchSaveInstanceState(View.java:4944) at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1052) at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1052) at android.view.View.saveHierarchyState(View.java:4927) at com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1314) at android.app.Activity.onSaveInstanceState(Activity.java:1055) at blah.blah.Blah.onSaveInstanceState(TodoEdit.java:110) at android.app.Activity.performSaveInstanceState(Activity.java:999) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1255) at blah.blah.BlahTest.testLoadingAndSavingState(TodoEditIntegrationTest.java:37) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:136) at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:126) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:155) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:142) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:313) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1508) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] How do you save the state of an activity on an ActivityUnitTestCase
Hello, In an ActivityUnitTestCase I'm trying to do: Activity activity = startActivity(INSERT_INTENT, initialState, null); Bundle outState = new Bundle(); getInstrumentation().callActivityOnSaveInstanceState(activity, outState); But on the save state call I get this trace: android.util.AndroidRuntimeException: Acquiring SearchManager objects only valid in Activity Contexts. at android.app.ApplicationContext.getSearchManager(ApplicationContext.java:976) at android.app.ApplicationContext.getSystemService(ApplicationContext.java:861) at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:73) at android.app.Activity.getSystemService(Activity.java:3091) at android.app.Activity.performSaveInstanceState(Activity.java:1004) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1255) at com.blah.blah.SomeActivityTest.testLoadingAndSavingState(SomeActivityTest.java:90) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:136) at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:126) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:155) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:142) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:313) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1508) Going through the ApplicationContext source code I've found this (http://tinyurl.com/d8qsyc): private SearchManager getSearchManager() { // This is only useable in Activity Contexts if (getActivityToken() == null) { throw new AndroidRuntimeException( Acquiring SearchManager objects only valid in Activity Contexts.); } synchronized (mSync) { if (mSearchManager == null) { mSearchManager = new SearchManager(getOuterContext(), mMainThread.getHandler()); } } return mSearchManager; } It seems the problem is that the activity token is not set. But here I'm puzzled, I don't know where to go next. Any ideas on how to fix it or workaround it are appreciated. I want to test that my application is saving its state correctly. Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Testing using ProviderTestCase and other classes in android.test
Hello, According to http://code.google.com/android/kb/troubleshooting.html#addjunit you have to remove the Android library from your tests to run them, but if you remove the Android library then you can't access classes such as android.test.ProviderTestCase; so how do you write or run a ProviderTestCase? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] _count column
Hello, What should I do to get my content provider to return the _count column with the count of records? Thanks. -- J. Pablo Fernández pup...@pupeno.com (http://pupeno.com) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Long click in ListActivity
Hello, Any ideas how to implement long click on the items of a ListActivity that is build using a ListAdapter and no layout, just the built in. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---