Hello i dsplayed notification and according to the distance from circle i displayed notification and i want to send all marker emailid to pending intent activity.
Here is my code
@Override
public void onLocationChanged(Location location) {
if (circle != null)
circle.remove();
this.location = location;
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
// googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(14));
circle = googleMap.addCircle(new CircleOptions()
.center(new LatLng(latitude, longitude))
.strokeColor(Color.RED)
.strokeWidth(2)
.radius(1000));
circle.setCenter(latLng);
float[] distance = new float[2];
if (!abc.isEmpty()) {
mar_list=new ArrayList<>();
for (int i = 0; i < abc.size(); i++) {
Location.distanceBetween(abc.get(i).latitude, abc.get(i).longitude, circle.getCenter().latitude, circle.getCenter().longitude, distance);
if (distance[0] <= circle.getRadius()) {
mar_list.add(locationlist.get(i).get("usrnm"));
manager1 = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(MainActivity.this, OfferActivity.class);
intent.putExtra("list",mar_list);
Log.v("TAG",""+mar_list.toString());
//Here mar_list contain three items but in offer activity only one item is displayed
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
mBuilder = new NotificationCompat.Builder(this);
mBuilder.setOngoing(false);
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
mBuilder.setContentTitle("Offer")
.setStyle(new NotificationCompat.BigTextStyle().bigText("You Have Entered in Offer zone.To see offer in your area please proceed"))
.setContentText("You Have Entered in Offer zone.To see offer in your area please proceed")
.setLargeIcon(largeIcon)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setAutoCancel(true)
.setSmallIcon(R.mipmap.ic_launcher);
manager1.notify(1, mBuilder.build());
} else {
Log.v("TAG ", "" + distance[0] + " radius: " + circle.getRadius());
Toast.makeText(getBaseContext(), "outside, distance from center: " + distance[0] + " radius: " + circle.getRadius(), Toast.LENGTH_LONG).show();
}
}
Log.v("TAG",""+mar_list.toString());
} else {
Log.v("TAG ", "" + distance[0] + " radius: " + circle.getRadius());
Toast.makeText(getBaseContext(), "outside, distance from center: " + distance[0] + " radius: " + circle.getRadius(), Toast.LENGTH_LONG).show();
}
}
According to my code it will pass only first value i want all arraylist to pass to next activity
here is offeractivity
public class OfferActivity extends AppCompatActivity {
ArrayList<String> mylist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offer);
mylist = (ArrayList<String>) getIntent().getSerializableExtra("list");
Log.v("TAG", "" + mylist.toString());
}
}