Guest User

Untitled

a guest
Nov 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public void amigos(String id){
  2.  
  3. // final String returnString="prueba " ;
  4.  
  5. //final String canamigo="0";
  6.  
  7.  
  8.  
  9.  
  10. new GraphRequest(
  11. AccessToken.getCurrentAccessToken(),
  12. "/me/friends",
  13. null,
  14. HttpMethod.GET,
  15. new GraphRequest.Callback() {
  16. public void onCompleted(GraphResponse response) {
  17. /* handle the result */
  18.  
  19. String nombres="nombres: ";
  20. String otro="nombres: ";
  21. try {
  22. JSONObject json_data=response.getJSONObject();
  23. JSONArray frienArray = ((JSONArray) (response.getJSONObject().get("data")));
  24.  
  25. System.out.println("este es el jsom"+json_data);
  26.  
  27.  
  28. //JSONArray aray=json_data.getJSONArray("data");
  29.  
  30. System.out.println("este es el array2"+frienArray.length());
  31.  
  32. if(frienArray!=null) {
  33. System.out.println("no es nulo "+frienArray);
  34. for (int i = 0; i < frienArray.length(); i++) {
  35.  
  36. JSONObject amigo = frienArray.getJSONObject(i);
  37. System.out.println("nombre de la persona :-"+amigo.getString("first_name"));
  38. otro= amigo.getString("first_name");
  39. }
  40. }
  41. TextView listaAmigos=(TextView) findViewById(R.id.nombres);
  42.  
  43. listaAmigos.setText(otro);
  44.  
  45. } catch (JSONException e) {
  46. e.printStackTrace();
  47. }
  48.  
  49.  
  50.  
  51. }
  52. }
  53. ).executeAsync();
  54.  
  55. TextView listaAmigos=(TextView) findViewById(R.id.nombres);
  56.  
  57. listaAmigos.setText(id);
  58.  
  59. Log.d(id, "onCompleted: esto es el id");
  60.  
  61.  
  62.  
  63.  
  64. }
Add Comment
Please, Sign In to add comment