I want to fake location in android. In android, there is a way for getting location using PendingIntent
. Here is an example:
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
String proximitys = "ACTION";
IntentFilter filter = new IntentFilter(proximitys);
LocationReceiver mReceiver = new LocationReceiver();
registerReceiver(mReceiver, filter);
Intent intent = new Intent(proximitys);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_CANCEL_CURRENT);
service.requestLocationUpdates("network", 1000, 0.001f, proximityIntent);
And BroadcastReceiver
will receive event when new location change:
public class LocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Do this when the system sends the intent
Bundle b = intent.getExtras();
Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);
}
}
So, I want to hook this method. But I don't know how to hook this kind of method (that using PendingIntent
). because PendingIntent
will have data in "some future", and I don't know when it will happen. So hooking both before and after of method requestLocationUpdates
seem not work because at that time, PendingIntent
doesn't have any data yet.
Please tell me how to do this.