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. Streaming buffer problem

Hi all,

I am trying to store the content of a streaming to a buffer array and
then a file and try to play from the file. The problem now is the
buffer cannot store the input stream. My code is something like this:
    private void saveStreaming() throws IOException{

        InetAddress inetAddress = InetAddress.getByName(IP_ADDR);
        Socket client = new Socket(inetAddress,5544);
                InputStream stream = client.getInputStream();
                Log.d(TAG,"Connection is established...");

                File temp=File.createTempFile("mediaplayertmp","dat");
                tempPath=temp.getAbsolutePath();
                FileOutputStream out=new FileOutputStream(temp);

                byte buf[]=new byte[200];
                do
                {
                Log.d(TAG,"stuck here");
                int numread = stream.read(buf);
                if(numread<=0)
                        break;
                out.write(buf, 0, numread);
                }while(true);

                Log.d(TAG,"SO DIFFICULT...I AM DYING...");

                mMediaPlayer.stop();
                stream.close();
                out.close();
                client.close();
    }

I check the logcat and the connection to the host post is built and
the "stuck here" information appears only once, followed by the
message "error (1,-11)", then I check the PVMF elements. -11 means
PVMFErrTimeout. Does anyone know what does that error mean and how to
solve that problem? Many thanks!

-- 

2. multicast working on some routers, not others

i am developing an app that will control a multi-room audio system. I
have implimented the following, which works fine on my own network at
home (cable modem and D-Link DIR 855 router), but does not work on the
office DSL Motorola modem/router. Our iPhone app and our Pronto
ProntoScript app work at both locations, so I know that the multicasts
are being sent properly. Any ideas?

        MulticastSocket ms = new MulticastSocket(CTInit.UDPPort);
        InetAddress UDPAddress = InetAddress.getByName(CTInit.UDPIPAddress);
        ms.joinGroup(UDPAddress);
        while (true) {
                DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
                ms.receive(dp);
                mcData = new String(dp.getData(),0,dp.getLength());


It is{*filter*} at ms.receive(dp), waiting to receive a multicast.

Just for more info, the ProntoScript (JavaScript) implementation, that
is working, looks like this, with the same port numbers and
IPAddresses:

        UDPPortNumber = Number(UDPResult.PortNumber);
        UDPIPAddress = String(UDPResult.IPAddress);
        update = new UDPSocket(UDPPortNumber);
        update.mcastJoin(UDPIPAddress);

-- 

3. Implement clock widget using pictures as numbers, and getting user location

4. Problem setting focus

5. What's on earth the SAX Parser changes between 2.1 and 2.2

6. Looking for help testing an app

7. Anybody experiencing a boost in sales since opening up to other countries?