Its now up and running with Handler
On 10 Sep, 12:53, HideCheck <hidech...@gmail.com> wrote:
> You need to use the Handler.
>
> http://developer.android.com/reference/android/os/Handler.html
>
> Handler handler = new Handler();
>
> ex)
> public void run() {
>
> handler.post(new Runnable() {
>
> public void run() {
> textview.setText("xxx");
>
> }
> });
>
> }
> }
>
> 2011/9/10 Kristoffer <kris.isak.v...@gmail.com>:
>
>
>
> > Hello.
>
> > I have been searching for answer how to update a textview from another
> > thread, i have found several answer that point to using "Handler" but
> > i dont know how i should implement that in my code, maybe you could
> > point it out for me.
>
> > Iam checking if the user is logged in or not to Twitter,
> > here is my code.
>
> > SettingsActivity.java
>
> > public void updateLoginStatus() {
> > Thread f = new Thread() {
> > public void run() {
>
> > final TextView loginStatus = (TextView)
> > findViewById(R.id.loginstatus);
> > loginStatus.setText("Logged into Twitter : " +
> > TwitterUtils.isAuthenticated(prefs));
>
> > }
>
> > };
> > f.start();
> > }
>
> > and here is the code in TwitterUtils.java
>
> > public static boolean isAuthenticated(SharedPreferences prefs) {
>
> > String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
> > String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
>
> > AccessToken a = new AccessToken(token,secret);
> > Twitter twitter = new TwitterFactory().getInstance();
> > twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
> > Constants.CONSUMER_SECRET);
> > twitter.setOAuthAccessToken(a);
>
> > try {
> > twitter.getAccountSettings();
> > return true;
> > } catch (TwitterException e) {
> > return false;
> > }
> > }
>
> > any good idees?
> > 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+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment