Hello.

I am working on an app that uses a Socket to connect to a controller
over TCP. The protocol library was written in Java and I am
implementing it in android via a Service.

SplashScreenActivity -> ConnectionService -> Connection

where the Connection class is a Thread that handles the communications
with the controller. It's where the Socket lives.

I'm using the Preferences mechanism to store the IP and Port. If I
feed the Socket the correct IP and Port, the Connection Service works
beautifully. However, I am trying to simulate a user entering the
wrong information and having the connection fail. The ultimate goal is
to present a dialog and offer the ability to "reconnect" or "update
settings". However, when I enter a wrong Port number, the application
simply hangs.

I was under the impression that Threads executed concurrently so I've
tried moving the call to start the Connection Service to a Thread, but
it still hangs the application.

Has anyone had experience with a similar situation? Any recommended
reading on how to prevent the call for a new Socket (with a bad
address or port) from locking up my app?

Thanks,
j

_snipet_SplashScreenActivity_
        makeConnection = new Runnable(){
            @Override
            public void run() {

                try {
                        Thread.sleep(500);
                    Intent bindIntent = new
Intent(SplashScreenActivity.this, ConnectionService.class);
                    bindService(bindIntent, mConnection,
Context.BIND_AUTO_CREATE);

                    startService(new Intent(SplashScreenActivity.this,
ConnectionService.class));

                } catch (InterruptedException e) {
                        Log.i("THREAD","Interrupted"+e);
                }
            }
        };
_end_snipet_SplashScreenActivity_

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to