Mapper Android |verified| - Facebook Friends

private void geocodeLocation(String locationName, String friendName) { Geocoder geocoder = new Geocoder(this); try { List<Address> addresses = geocoder.getFromLocationName(locationName, 1); if (!addresses.isEmpty()) { Address address = addresses.get(0); LatLng position = new LatLng(address.getLatitude(), address.getLongitude()); FriendLocation friend = new FriendLocation( friendName, locationName, position.latitude, position.longitude ); allFriends.add(friend); addMarkerToMap(friend); } } catch (Exception e) { e.printStackTrace(); } }

</LinearLayout> </androidx.cardview.widget.CardView> facebook friends mapper android

private void setupFacebookLogin() { loginButton.setOnClickListener(v -> performFacebookLogin()); } private void geocodeLocation(String locationName

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" app:cardElevation="4dp"> try { List&lt

private void performFacebookLogin() { LoginManager.getInstance().logInWithReadPermissions( this, Arrays.asList("public_profile", "user_friends") ); LoginManager.getInstance().registerCallback( new CallbackManager.Factory().create(), new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { fetchFriendsAndLocations(); } @Override public void onCancel() { Toast.makeText(FacebookFriendsMapperActivity.this, "Login cancelled", Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException error) { Toast.makeText(FacebookFriendsMapperActivity.this, "Login error: " + error.getMessage(), Toast.LENGTH_SHORT).show(); } } ); }

public class FacebookFriendsMapperActivity extends AppCompatActivity implements OnMapReadyCallback {

private void fetchFriendsAndLocations() { progressBar.setVisibility(View.VISIBLE); statusText.setText("Loading friends..."); GraphRequest request = GraphRequest.newMeRequest( AccessToken.getCurrentAccessToken(), (object, response) -> { if (object != null) { try { JSONObject friends = object.getJSONObject("friends"); JSONArray data = friends.getJSONArray("data"); for (int i = 0; i < data.length(); i++) { JSONObject friend = data.getJSONObject(i); String name = friend.getString("name"); String id = friend.getString("id"); // Fetch friend's location info fetchFriendLocation(id, name); } statusText.setText("Found " + data.length() + " friends"); progressBar.setVisibility(View.GONE); } catch (Exception e) { e.printStackTrace(); statusText.setText("Error parsing friends data"); } } } ); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,friends.limit(100){id,name,location}"); request.setParameters(parameters); request.executeAsync(); }