1

This is part of the code, and the question is, how can I INTENT this values

            Log.i(TAG, "Display Name: " + person.getDisplayName());
            Log.i(TAG, "Gender: " + person.getGender());
            Log.i(TAG, "About Me: " + person.getAboutMe());
            Log.i(TAG, "Birthday: " + person.getBirthday());
            Log.i(TAG, "Current Location: " + person.getCurrentLocation());
            Log.i(TAG, "Language: " + person.getLanguage());

To another activity.

My idea which do not work is to do it like this

            userGenderG = person.getGender();
            userAboutG = person.getAboutMe();
            userBirthdayG = person.getBirthday();
            userLanguageG = person.getLanguage();

Unsuccessful idea.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);

        // G+
        if (mGoogleApiClient.hasConnectedApi(Plus.API)) {
            Person person  = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
            if (person != null) {
                Log.i(TAG, "--------------------------------");
                Log.i(TAG, "Display Name: " + person.getDisplayName());
                Log.i(TAG, "Gender: " + person.getGender());
                Log.i(TAG, "About Me: " + person.getAboutMe());
                Log.i(TAG, "Birthday: " + person.getBirthday());
                Log.i(TAG, "Current Location: " + person.getCurrentLocation());
                Log.i(TAG, "Language: " + person.getLanguage());

                userGenderG = person.getGender();
                userAboutG = person.getAboutMe();
                userBirthdayG = person.getBirthday();
                userLanguageG = person.getLanguage();

            } else {
                Log.e(TAG, "Error!");
            }
        } else {
            Log.e(TAG, "Google+ not connected");
        }
    }
}

Any suggestion about how could I user gender as value and intent them to another activity?

UPDATED (how send data)

 GoToNewActivity.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent intent = new Intent(MainActivity.this, Index.class);

                    Bundle extras = new Bundle();
                    extras.putString("userGender", userGenderG);
                    extras.putString("userAbout", userAboutG);
                    extras.putString("userBirthday", userBirthdayG);
                    extras.putString("userLanguage", userLanguageG);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });
  • If you're getting values, you can pass the value using intent. Follow this link http://stackoverflow.com/questions/11303887/how-can-i-transfer-the-data-between-two-activities-in-android – Paresh P. Apr 10 '16 at 14:15
  • This is the problem how to GET the value, but by using my method, O can't get value –  Apr 10 '16 at 14:17
  • By using intent and this method, result which is displayed is null –  Apr 10 '16 at 14:30
  • @J.FOG I think you can pass `person` values to a string array, then pass that string array to another activity (http://stackoverflow.com/questions/8892916/how-to-pass-a-string-array-value-from-one-activity-to-another-activity-in-androi) – BNK Apr 11 '16 at 06:01
  • @BNK I have tried, and it do not work, that's why I ask here. I lf I simple intent the value to another activity, i have error or null(because i set defaul value to be null) or incorect value –  Apr 12 '16 at 12:23
  • I could not see where you sent that data to another activity – BNK Apr 12 '16 at 13:39
  • @BNK I will update later, i was using Bundle and Intent extra to send value to another activity. –  Apr 12 '16 at 21:08
  • @BNK Updated have a look –  Apr 12 '16 at 22:36
  • Are you sure person's values not null? Have you check them yet? Show your logcat output – BNK Apr 12 '16 at 23:40
  • Yes I have made account gender = female and outcome still 0 (which is male) –  Apr 13 '16 at 00:45

0 Answers0