I would use an AsyncTask for that, but Handler works too. Both are
explained with examples here:
http://www.vogella.de/articles/AndroidPerformance/article.html#concurrency

On 10 Sep, 12:23, Kristoffer <kris.isak.v...@gmail.com> wrote:
> 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to