Hi,
I am new to android Twitter ,I use Oauth to access twitter account every process is working fine.But once after getting Access token I have to change orientation of emulator or some other changes to be done to store the access tokens . here i use shared preference to store values .I don't know where i do mistakes pls can anyone help me . following is my code where i find problem. Token = mSharedPreference.getString("AccessToken.token",null); Log.e("","Token-- "+Token); Tokensecret = mSharedPreference.getString("AccessToken.tokenSecret",null); Log.e("","Token-- "+Tokensecret); ScreenName = mSharedPreference.getString("AccessToken.ScreenName",null); Log.e("","Token-- "+ScreenName); if (Token==null && Tokensecret == null && ScreenName == null ) { askoAuth(); } btntimeline.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (Token!=null && Tokensecret != null && ScreenName! =null ) { Intent intent = new Intent(IdeaTwit.this,Tabclass.class); startActivity(intent); } else { askoAuth(); } } }); public void askoAuth() { // TODO Auto-generated method stub try{ System.setProperty("twitter4j.http.useSSL","false"); System.setProperty("twitter4j.oauth.consumerKey","k5pQGDNFMiiLKn6sc9DQ"); System.setProperty("twitter4j.http.consumerSecret","eM8hkPVmyw7C60e6f6CrMLdn0A5oqVWZNaD9z7xU5Zg"); System.setProperty("twitter4j.oauth.requestTokenURL","http:// api.twitter.com/oauth/request_token"); System.setProperty("twitter4j.oauth.accessTokenURL","http:// api.twitter.com/oauth/access_token"); System.setProperty("twitter4j.oauth.authorizationURL","http:// api.twitter.com/oauth/authorize"); twitter.setOAuthConsumer("k5pQGDNFMiiLKn6sc9DQ","eM8hkPVmyw7C60e6f6CrMLdn0A5oqVWZNaD9z7xU5Zg"); requestToken = twitter.getOAuthRequestToken(CALL_BACK); Toast.makeText(this,"Please Authorize this App!",Toast.LENGTH_LONG).show(); this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL()))); } catch(Exception e) { Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show(); } } public void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri uri=intent.getData(); if (uri!= null && uri.toString().startsWith(CALL_BACK)) { String verifier=uri.getQueryParameter("oauth_verifier"); try { AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); SharedPreferences.Editor e=mSharedPreference.edit(); e.putString("AccessToken.token",accessToken.getToken()); e.putString("AccessToken.tokenSecret",accessToken.getTokenSecret()); e.putString("AccessToken.ScreenName",accessToken.getScreenName()); e.commit(); twitter=new TwitterFactory().getOAuthAuthorizedInstance(CONSUMER_KEY,CONSUMER_SECRET,accessToken); //Date d = new Date(System.currentTimeMillis()); String tweet=" #0Auth Working! "; twitter.updateStatus(tweet); //tweetTextView.setText(tweet); Toast.makeText(this,tweet,Toast.LENGTH_LONG).show(); btntimeline.setEnabled(true); } catch (Exception e) { Toast.makeText(this, e.getMessage(),Toast.LENGTH_LONG).show(); } } -- 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