0

I am looking for a way to send text from EditText, to a friend with the app installed, so that the friend recieves the "message" inside the app, and not on the actual facebook. In the edittext when you have written X amount of characters, you are redirected to a ListView which fetches friends from facebook, so how could i bring the text from EditText to the next activity, and then eventually send it to the facebook friend?

Any tips on how i should go from here would be appreciated :)

Here is the listview i have:

// populate list
            List<String> values = new ArrayList<String>();
            for (Profile profile : friends) {
                //profile.getInstalled();
                values.add(profile.getName());
                }



            ArrayAdapter<String> friendsListAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.list_items2, values);
            friendsListAdapter.sort(new Comparator<String>() {
                @Override
                public int compare(String lhs, String rhs) {
                    return lhs.compareTo(rhs);    
                }
            });
da_st
  • 402
  • 2
  • 10
  • 27

1 Answers1

1

to get the text from the EditText use

String message = yourEdit.getText().toString();

To send the message to another activity use the bundle, which is included in the intent

Intent intent = new Intent(this, targetActivity.class);
intent.putExtra("KEY_TO_IDENTIFY_MESSAGE", message);
startActivity(intent);

In targetActivity.class call getIntent()

Intent intent = getIntent();
String message = intent.getStringExtra("KEY_TO_IDENTIFY_MESSAGE");

To send the message to your friend you have to connect to the FacebookAPI

speedy1034
  • 304
  • 2
  • 9
  • Thanks! I am connected to the FacebookAPI, how can i send to a friend from there? :) – da_st Apr 14 '14 at 19:57
  • Hey check [How to send private messages with Facebook API](http://stackoverflow.com/questions/2574431/send-private-messages-to-friends) – speedy1034 Apr 14 '14 at 19:59