Facebook Friends Mapper Android [portable] -

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(); } }

private void fetchFriendLocation(String friendId, String friendName) { GraphRequest request = GraphRequest.newGraphPathRequest( AccessToken.getCurrentAccessToken(), friendId, response -> { try { JSONObject friendData = response.getJSONObject(); if (friendData.has("location")) { JSONObject location = friendData.getJSONObject("location"); String locationName = location.getString("name"); // Geocode location name to coordinates geocodeLocation(locationName, friendName); } } catch (Exception e) { // No location available for this friend } } ); Bundle params = new Bundle(); params.putString("fields", "location"); request.setParameters(params); request.executeAsync(); } facebook friends mapper android

<TextView android:id="@+id/statusText" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="8dp" android:text="Ready" android:textSize="12sp" /> </LinearLayout> AndroidManifest.xml ; import com

<Button android:id="@+id/loginButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="FB Login" /> private void geocodeLocation(String locationName

package com.example.friendsmapper; import android.Manifest; import android.content.pm.PackageManager; import android.location.Location; import android.os.Bundle; import android.widget. ; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.facebook. ; import com.facebook.login.LoginManager; import com.facebook.login.LoginResult; import com.google.android.gms.maps. ; import com.google.android.gms.maps.model. ; import com.google.android.gms.tasks.OnSuccessListener; import org.json.JSONArray; import org.json.JSONObject; import java.util.*;

Scroll to Top