Android Open Source - NewAndroidTwitter Base Activity






From Project

Back to project page NewAndroidTwitter.

License

The source code is released under:

Apache License

If you think the Android project NewAndroidTwitter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.londatiga.android.example;
/*ww w. j  av  a2s .com*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class BaseActivity extends Activity {
  private SharedPreferences mSharedPref;
  
  private static final String SHARED_PREF = "android_twitter";
  private static final String USER_SCREEN_NAME = "tw_user_id";
  private static final String USER_NAME = "tw_user_name";
  private static final String USER_PIC = "tw_user_pic";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    mSharedPref  = getSharedPreferences(SHARED_PREF, Context.MODE_PRIVATE);
  }
  
  public void saveCredential(String screenName, String name, String profilePic) {
    Editor editor = mSharedPref.edit();
    
    editor.putString(USER_SCREEN_NAME, screenName);
    editor.putString(USER_NAME, name);
    editor.putString(USER_PIC, profilePic);
    
    editor.commit();
  }
  
  public void clearCredential() {
    Editor editor = mSharedPref.edit();
    
    editor.putString(USER_SCREEN_NAME, "");
    editor.putString(USER_NAME, "");
    editor.putString(USER_PIC, "");
    
    editor.commit();
  }
  
  public String getScreenName() {
    return mSharedPref.getString(USER_SCREEN_NAME, "");
  }
  
  public String getUserName() {
    return mSharedPref.getString(USER_NAME, "");
  }
  
  public String getProfilePicture() {
    return mSharedPref.getString(USER_PIC, "");
  }
  
  public void showToast(String text) {
    Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG).show();
  }
  
  public Activity getActivity() {
    return this;
  }
}




Java Source Code List

net.londatiga.android.example.BaseActivity.java
net.londatiga.android.example.MainActivity.java
net.londatiga.android.example.UserActivity.java
net.londatiga.android.twitter.TwitterDialog.java
net.londatiga.android.twitter.TwitterRequest.java
net.londatiga.android.twitter.TwitterUser.java
net.londatiga.android.twitter.Twitter.java
net.londatiga.android.twitter.http.HttpConn.java
net.londatiga.android.twitter.http.HttpParams.java
net.londatiga.android.twitter.http.HttpValues.java
net.londatiga.android.twitter.oauth.OauthAccessToken.java
net.londatiga.android.twitter.oauth.OauthConsumer.java
net.londatiga.android.twitter.oauth.OauthHeader.java
net.londatiga.android.twitter.oauth.OauthProvider.java
net.londatiga.android.twitter.oauth.OauthSignature.java
net.londatiga.android.twitter.oauth.OauthToken.java
net.londatiga.android.twitter.oauth.OauthUtil.java
net.londatiga.android.twitter.util.Base64.java
net.londatiga.android.twitter.util.Cons.java
net.londatiga.android.twitter.util.Debug.java
net.londatiga.android.twitter.util.StringUtil.java
net.londatiga.android.twitter.util.URIUtil.java