Code example for PlusClient

Methods: getCurrentPersonisConnectedloadMoments

0
        twitterService.processOauthCallback(getIntent().getData());
 
    } 
 
    private void loadMPlusMessages() { 
        mPlusClient.loadMoments(new PlusClient.OnMomentsLoadedListener() {
            @Override 
            public void onMomentsLoaded(ConnectionResult connectionResult, MomentBuffer moments, String s, String s2) {
                int count = moments.getCount();
            } 
        }); 
    } 
 
    public void loadTwitterMessages(View view) {
        twitterService.loadMessages();
        facebookService.loadMessages();
    } 
 
    public void showTwitterMessage(View view) {
        showMessagePage(view);
    } 
 
    public void authenticateTwitter(View view) {
        twitterService.requestOauthentication();
    } 
 
//    @Override 
//    protected void onResume() { 
//        super.onResume(); 
//        if (this.getIntent()!=null && this.getIntent().getData()!=null){ 
//            Uri uri = this.getIntent().getData(); 
//            if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { 
//                String verifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER); 
//                try { 
//                    // this will populate token and token_secret in consumer 
//                    provider.retrieveAccessToken(consumer, verifier); 
// 
//                    // Get Access Token and persist it 
//                    AccessToken a = new AccessToken(consumer.getToken(), consumer.getTokenSecret()); 
//                    storeAccessToken(a); 
// 
//                    // initialize Twitter4J 
//                    twitter = new TwitterFactory().getInstance(); 
//                    twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); 
//                    twitter.setOAuthAccessToken(a); 
//                    ((TwitterApplication)getApplication()).setTwitter(twitter); 
//                    //Log.e("Login", "Twitter Initialised"); 
// 
//                    startFirstActivity(); 
// 
//                } catch (Exception e) { 
//                    //Log.e(APP, e.getMessage()); 
//                    e.printStackTrace(); 
//                    Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 
//                } 
//            } 
//        } 
//    } 
 
 
 
    public void showMessagePage(View view) {
        startActivity(new Intent(getApplicationContext(), MessageActivity.class));
    } 
 
    public void showMessage(View view) {
       EditText editText = (EditText) findViewById(R.id.editText);
        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setMessage(editText.getText()+getHangoutParticipants());
        dialog.show();
    } 
 
    public void showinfo(View view) {
        AlertDialog dialog = new AlertDialog.Builder(this).create();
        if(mPlusClient.isConnected()) {
            dialog.setMessage(getHangoutParticipants());
        } else { 
           dialog.setMessage("Please Sign in");
        } 
        loadMPlusMessages(); 
        //dialog.show(); 
//        Plus.Activities.List listActivities = plus.activities().list("me", "public"); 
//        listActivities.setMaxResults(5L); 
//        // Pro tip: Use partial responses to improve response time considerably 
//        listActivities.setFields("nextPageToken,items(id,url,object/content)"); 
//        ActivityFeed feed = listActivities.execute(); 
    } 
 
    public void onClick(View view){
 
        if(view.getId() == R.id.sign_in_button && mPlusClient.isConnected()) {
            AlertDialog dialog = new AlertDialog.Builder(this).create();
            dialog.setMessage("Already signed in");
            dialog.show();
        } 
        if (view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
            if (mConnectionResult == null) {
                mConnectionProgressDialog.show();
            } else { 
                try { 
                    mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                } catch (IntentSender.SendIntentException e) {
                    // Try connecting again. 
                    mConnectionResult = null;
                    mPlusClient.connect();
                } 
            } 
        } 
    } 
 
    private String getHangoutParticipants() {
        Person currentPerson = mPlusClient.getCurrentPerson();
        StringBuilder sb = new StringBuilder();
        sb.append("The crazy information people can get when you accept permissions:").append("\n");
        sb.append("Name:" + currentPerson.getDisplayName()).append("\n");
        sb.append("Birthday:" + currentPerson.getBirthday()).append("\n");
        Location mCurrentLocation = mLocationClient.getLastLocation();