Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

extra credit display info of friends in a new activity

i there i am doing the extra credit challenge from the "ribbit app" where i need to acquire extra info from the user, save them in Parse.com and then display them in a new activity, so far i managed to acquire and save new info for new profile i also created a new activity to display them but one i click on it the page is empty how can i visualise the content of it? Ben Jakuben

5 Answers

Well as I understand, you already got all the data about the users from query in this activity.

What I would do is create an Intent which leads to next activity (show user info one). Put extra (user info class), which contains only info about the user clicked on. Than use intent.get in user info class to get all the data you need.

I also agree with George here and think this is the best way to go about this - as you're only going to be showing one users data, you can just get the data of that user and send it off in an Intent (Or you can just pass along their username and do the get the extra data in that activity/another class).

Either way, you'll get the same result, it's just personal preference how you wish to organise it :)

Can you show code, which you use in you second activity to display info?

public class FriendsProfileActivity extends ActionBarActivity{

    public static final String TAG = FriendsProfileActivity.class.getSimpleName();


    @Override
    protected void onResume() {
        super.onResume();

        ParseQuery<ParseUser> query = ParseUser.getQuery();
        query.orderByAscending(ParseConstant.KEY_USERNAME);
        query.setLimit(10);
        query.findInBackground(new FindCallback<ParseUser>() {
            @Override
            public void done(List<ParseUser> users, com.parse.ParseException e) {

                if (e == null) {

                }
                else {
                    Log.e(TAG, e.getMessage());
                    AlertDialog.Builder builder = new AlertDialog.Builder(FriendsProfileActivity.this);
                    builder.setMessage(e.getMessage())
                            .setTitle(R.string.error_title)
                            .setPositiveButton(android.R.string.ok, null);
                    AlertDialog dialog = builder.create();
                    dialog.show();
                }

        }
    });

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_friends_profile);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_friends_profile, menu);
        return true;
    }

}




//everything i tried in the if (e==null) condition failed

What if you try making code in try/catch instead of if/else

try {

} catch (e) {

Log.e(TAG, e.getMessage());
                AlertDialog.Builder builder = new AlertDialog.Builder(FriendsProfileActivity.this);
                builder.setMessage(e.getMessage())
                        .setTitle(R.string.error_title)
                        .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();

}

it is working with if/else, my problem is that i don't how to display the ParseObject