ViewFlipper not working inside a class which extends LinearLayout

by Nithin » Thu, 22 Apr 2010 22:59:00 GMT


Sponsored Links
 Hi,

When I tried to create a ViewFlipper inside a class which extends
LinearLayout, its throwing an exception

"java.lang.RuntimeException: Can't create handler inside thread that
has not called Looper.prepare()".

I am creating the ViewFlipper using,

ViewFlipper flipper = new ViewFlipper(ctContext);

But when I create the ViewFlipper in a class which extends Activity,
its working normally. What may the reason ?

Nithin

--



ViewFlipper not working inside a class which extends LinearLayout

by Streets Of Boston » Fri, 23 Apr 2010 01:25:50 GMT


 What thread is calling 'new ViewFlipper(ctContext)'?
Is it the main UI-thread?
If not, the calling thread must have a message-loop associated with it
(A looper-thread).
If it's not a looper-thread, you can't call 'new
ViewFlipper(ctContext)' this way.



>


Sponsored Links


ViewFlipper not working inside a class which extends LinearLayout

by Nithin » Fri, 23 Apr 2010 02:07:54 GMT


 Thanks for your reply.. solved the issue..

I put the flipper creation code inside the runOnUIThread() and its
working fine..

Nithin

On Apr 22, 10:25pm, Streets Of Boston <flyingdutc...@gmail.com>



> >



Other Threads

1. My appwidget broken Donut when keyboard slide out/in

I developed an appwidget and published on market, it works very well
on Cupcake. but after I upgrade my OS to Donut.Everytime when I slide
out/in keyboard, I will got an error:

The process android.process.acore has stopped unexpected.Please try
again.

I have to click "force close", and wait about 3 seconds to get the
home screen. It seems my appwidget cause this error, because after I
uninstall the appwidget, the error also gone. One of my user reported
to me the same problem, he was sure it's my appwidget's problem,
because he erase all application and install one by one to test which
application cause the error, he found after he installed my appwidget,
the error occured again.

It's very strange,I checked Donut documents, seems the appwidget api
have no change.I don't know what happend when keyboard slide out/in,
does any body know why this happen?

below is the log capture from DDMS when the error occured.


10-20 22:50:28.503: DEBUG/AndroidRuntime(764): Shutting down VM

10-20 22:50:28.503: WARN/dalvikvm(764): threadid=3: thread exiting
with uncaught exception (group=0x4001da28)

10-20 22:50:28.523: ERROR/AndroidRuntime(764): Uncaught handler:
thread main exiting due to uncaught exception

10-20 22:50:28.703: ERROR/AndroidRuntime(764):
java.lang.ClassCastException: android.view.AbsSavedState$1

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.launcher.Workspace.onRestoreInstanceState(Workspace.java:
903)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.view.View.dispatchRestoreInstanceState(View.java:5689)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
1121)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
1125)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
1125)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.view.View.restoreHierarchyState(View.java:5668)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState
(PhoneWindow.java:1506)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.app.Activity.onRestoreInstanceState(Activity.java:833)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.launcher.Launcher.finishBindDesktopItems(Launcher.java:
1508)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.launcher.Launcher.bindItems(Launcher.java:1472)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.launcher.Launcher.access$2400(Launcher.java:90)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.launcher.Launcher$DesktopBinder.handleMessage
(Launcher.java:2225)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.os.Handler.dispatchMessage(Handler.java:99)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.os.Looper.loop(Looper.java:123)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
android.app.ActivityThread.main(ActivityThread.java:4203)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
java.lang.reflect.Method.invokeNative(Native Method)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
java.lang.reflect.Method.invoke(Method.java:521)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

10-20 22:50:28.703: ERROR/AndroidRuntime(764):     at
dalvik.system.NativeStart.main(Native Method)

10-20 22:50:28.713: INFO/Process(81): Sending signal. PID: 764 SIG: 3

10-20 22:50:28.713: INFO/dalvikvm(764): threadid=7: reacting to signal
3

10-20 22:50:28.963: INFO/dalvikvm(764): Wrote stack trace to '/data/
anr/traces.txt'

10-20 22:50:29.313: INFO/DumpStateReceiver(81): Added state dump to 1
crashes

10-20 22:50:31.003: DEBUG/dalvikvm(81): GC freed 10815 objects /
597576 bytes in 274ms
--~--~---------~--~----~------------~-------~--~----~

2. Google Streetview for 2.0 emulator, to test invocation through an Intent

My apps invoke Google Streetview through an Intent (as document here:
http://developer.android.com/intl/zh-TW/guide/appendix/g-app-intents.html).
Right now I am testing things out for Android 2.0. In the absence of a
physical device, this is through emulator testing only, for now.
I noticed the Google apps, which are needed to test the above, are
missing in  2.0. I did some poking around but couldn't find a source
to install those on the emulator (I am aware there's been some
commotion around that aspect of Android...). So I tried the Cyanogen
(sp?) route, pull Street.apk off a 1.6 device and then adb install it
in the emulator. That didn't work... Street.apk is reported as already
existing, and I cannot replace it ("failure").
BTW: I cross checked this method against Maps.apk, and that went
through OK.

Anybody got an idea how to properly install street view on the 2.0
emulator? (Did I fundamentally miss something here?)

--~--~---------~--~----~------------~-------~--~----~

3. Eclais SDK is out, but STILL no Arabic support in Android

4. Turn copy protection from on to off on market app?

5. Run ARM application on Qualcomm 3G

6. Slashdot: Android / Windows 7 Dual Boot Netbook Disappoints

7. Using TransitionDrawable to make a transition with 3 elements