Java 类com.parse.ParseTwitterUtils 实例源码

项目:Bookd_Android_App    文件:SignOnFragment.java   
private void signInTwitter() {
    ParseTwitterUtils.logIn(getActivity(), new LogInCallback() {
        @Override
        public void done(ParseUser parseUser, ParseException e) {
            if (e == null) {
                boolean fullyRegistered = parseUser.getBoolean(ParseTables.Users.FULLY_REGISTERED);
                if (parseUser == null) {
                    Log.d(TAG, "Uh oh. The user cancelled the Twitter login.");
                } else if (!fullyRegistered || parseUser.isNew()) {
                    Log.d(TAG, "User signed up and logged in through Twitter!");
                    getTwitterData();
                } else {
                    Log.d(TAG, "User logged in through Twitter!");
                    Utils.goToMainActivity(getActivity());
                }
            } else {
                e.printStackTrace();
            }
        }
    });
}
项目:Bookd_Android_App    文件:ApplicationWrapper.java   
@Override
public void onCreate() {
    super.onCreate();
    Fresco.initialize(this);
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, "Qkf0ETa2dogBX3ot1BgSswy09PR6fAK6vJEMGcof", "KqV8lTovHNQQPuZ819qzCHK617uXvJIkWpxaqLkf");
    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    ParseFacebookUtils.initialize(this);
    ParseTwitterUtils.initialize("J3ncUDAVwYhOPRadv1kD7Z75G","bVSeScEZB8u7jFnLQmtk0FiCTdw1vIJJpfapTDrHDoVFLEOFCP");
}
项目:Studddinv2_android    文件:ApplicationWrapper.java   
@Override
    public void onCreate() {
        super.onCreate();
//        Parse.enableLocalDatastore(this);
        Parse.initialize(this, "9nhyJ0OEkfqmGygl44OAYfdFdnapE27d9yj9UI5x", "7pJlc2KZgpFXZHwvoXwVeZUsEtiDoTrtjPM7EGBa");
        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();
        ParseFacebookUtils.initialize(this);
        ParseTwitterUtils.initialize("FfUOeQ5OBuv0qOkdHbfXCrwdk", "xQmFnUSii54eS3iUrl0uIrxfeL4EfIdFc6iyoHUDgSIVGDbauD");
        Fresco.initialize(this);
    }
项目:Greplr_Android    文件:App.java   
@Override
public void onCreate() {
    SharedPreferences sPref = getSharedPreferences("location", MODE_PRIVATE);
    currentLatitude = Double.valueOf(sPref.getString("lastLatitude", "28.6328"));
    currentLongitude = Double.valueOf(sPref.getString("lastLongitude", "77.2197"));
    Parse.initialize(this, "tA24P8ZHIuY6T6GCePmlwS94r7DKYIl0DrYee41g", "1pJVaZcK43AXO6wAtDzqPs1GMkA1E3jHtXTNCzKc");
    ParseFacebookUtils.initialize(this);
    ParseTwitterUtils.initialize("PdLB1zaNjktVXpBqPddVMWENt", "ND4JkQj7lucz1uQO0URF3mBfQFORIzSKY2oHUPZGtJgbaDzZLY");
    buildGoogleApiClient();
    super.onCreate();

}
项目:ISawABird    文件:LoginActivity.java   
public void loginTwitter(View view) {

        showActivityIndicator();

        // network not available
        if (!Utils.isNetworkAvailable(getApplicationContext())) {
            Toast.makeText(getApplicationContext(), "Network not available", Toast.LENGTH_SHORT).show();
            hideActivityIndicator();
            return;
        }

        ParseTwitterUtils.initialize(ParseConsts.TWITTER_CONSUMER_KEY, ParseConsts.TWITTER_CONSUMER_SECRET);
        ParseTwitterUtils.logIn(this, new LogInCallback() {

            @Override
            public void done(ParseUser user, ParseException ex) {
                hideActivityIndicator();
                if (user == null) {
                    String errMsg ; 
                    if (ex == null){
                        errMsg = "Sorry, but looks like you cancelled the Twitter login";
                    }else {
                        errMsg = "Unable to login using Twitter " + ex.getMessage(); 
                    }
                    Toast.makeText(getApplicationContext(), errMsg, Toast.LENGTH_SHORT).show();
                } else {
                    Utils.setCurrentUsername(user.getUsername());
                    saveInstallationID();
                    showHome();
                }
            }
        });
    }
项目:Studddinv2_android    文件:SignOnFragment.java   
public void doTwitterSignOn(View v) {
        mProgressDialog.setMessage("Signing in via Twitter");
        mProgressDialog.show();
        ParseTwitterUtils.logIn(getActivity(), new LogInCallback() {
            @Override
            public void done(ParseUser user, ParseException err) {
                mProgressDialog.dismiss();
                if (err != null) {
                    err.printStackTrace();
                    return;
                }
                if (user == null) {
                    Log.w(TAG, "Uh oh. The user cancelled the Twitter login.");
                } else {
                    boolean fullyRegistered = false;
                    try {
                        fullyRegistered = user.getBoolean(ParseTables.Users.FULLY_REGISTERED);
                    } catch (Exception ignored) {
                    }

                    if (user.isNew() || (!fullyRegistered)) {
                        Log.w(TAG, "User signed up and logged in through Twitter!" + ParseTwitterUtils.getTwitter().getScreenName());
                        TwitterApi.getTwitterData(new TwitterApi.TwitterDataCallback() {
                            @Override
                            public void gotData(Bundle bundle) {
//                                final SignupDataFragment fragment = showSignupDataFragment(bundle);
                                new PushUserIntoParse().execute(bundle);
                                /*
                                TwitterApi.getUserInfo(new TwitterApi.TwitterInfoCallback() {
                                    @Override
                                    public void gotInfo(JSONObject object, Bitmap profileBitmap, Bitmap coverBitmap) throws JSONException {
                                        fragment.profileBitmap = profileBitmap;
                                        fragment.bitmapReady = true;
                                        fragment.setProfilePicture();
                                        fragment.setCoverPicture(coverBitmap);
                                    }
                                });*/
                            }
                        });
                    } else {
                        Log.w(TAG, "User logged in through Twitter!");
                        SignupDataFragment.goToMainActivity(getActivity());
                    }
                }
            }
        });
    }
项目:TemplateAppParse-dot-com    文件:LoginActivity.java   
@Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_login);

       Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
       setSupportActionBar(toolbar);

       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
           Window window = getWindow();
           window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
           window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
           window.setStatusBarColor(getResources().getColor(R.color.primary_dark));
       }

       mUsernameField = (EditText) findViewById(R.id.login_email);
       mPasswordField = (EditText) findViewById(R.id.login_password);
       mErrorField = (TextView) findViewById(R.id.error_messages);

       spinner = (ProgressBar)findViewById(R.id.progressBar1);
       spinner.setVisibility(View.GONE);

       Parse.initialize(this);

       Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
/** Get twitter auth data - In parse create new table , in this template I have called it "tw" & add string type columns "keyid" & "secretid"
 *  The benefit of this method is that if you need to revoke twitter keys, you just need to modify them in the table only. No need to for new app update.
 *  If you want to avoid doing it this way, then simply remove whole of the below code with just this one line & pass your keys as parameters.
 *  ParseTwitterUtils.initialize(tw_consumer_key, tw_consumer_secret);
 *  But with this you will have to push an app update in case you revoke your twitter keys.
 */
       ParseQuery<ParseObject> qtw = ParseQuery.getQuery("tw");
       qtw.getFirstInBackground(new GetCallback<ParseObject>() {
           @Override
           public void done(ParseObject obj, ParseException e) {
               if(e==null){
                       String tw_consumer_key = obj.get("keyid").toString();
                       String tw_consumer_secret = obj.get("secretid").toString();
                       ParseTwitterUtils.initialize(tw_consumer_key, tw_consumer_secret);
               }
               else {
                   Log.d("Tw: Error", e.getMessage());
               }
           }

       });
   }