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 [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