Why couldn't a callback be used here?
in your myObserver class create an interface for your callback:
-----------------------------------------------------------
public OnConnectListener listener;
public void setOnConnectListener(OnConnectListener listener) {
this.listener = listener;
}
public interface OnConnectListener {
public abstract void onConnect();
}
-----------------------------------------------------------
Then when your myObserver class connects you can call
listener.onConnect(); to send a callback to your activity.
This interface will have to be implemented in your activity like so:
__________________________________
myObserver tester = new myObserver()
tester.setOnConnectListener(new OnConnectListener() {
@Override
public void onConnect() {
txtview.setEnabled(false);
}
});
Hope that works for you. I find it's a very sleek way of handling
updating the UI based on external events.
-Matthew Patience
On Aug 20, 7:48 am, Mark Murphy <[email protected]> wrote:
> On Sat, Aug 20, 2011 at 7:38 AM, Ash <[email protected]> wrote:
> > Assuming runOnUIThread is equivalent to AsyncTasks
> >http://developer.android.com/reference/android/os/AsyncTask.html
>
> AsyncTask is a class. runOnUiThread() is a method. You pass a Runnable
> to runOnUiThread(), and if you are on a background thread, the
> Runnable is posted to the main application thread's work queue for
> eventual processing. Whatever is inside the run() method of the
> Runnable is guaranteed to run on the main application thread.
>
> For example, here is a listener from an AIDL-defined remote service
> that uses runOnUiThread() to ensure that the events are passed to the
> activity on the main application thread:
>
> private final IScriptResult.Stub callback=new IScriptResult.Stub() {
> public void success(final String result) {
> runOnUiThread(new Runnable() {
> public void run() {
> successImpl(result);
> }
> });
> }
>
> public void failure(final String error) {
> runOnUiThread(new Runnable() {
> public void run() {
> failureImpl(error);
> }
> });
> }
> };
>
> This is an instance of an anonymous inner class of the activity
> itself, so successImpl() and failureImpl() are methods on the
> activity.
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.6 Available!
--
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