0
        nearby_locations.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
            startActivityForResult(builder.build(getApplicationContext()), PLACE_PICKER_REQUEST);

        }
    });

The getApplicationContext() in builder.build is underlined with an error saying it is looking for an activity not a context. I've tried casting but no luck, what should I do?

Tim
  • 41,901
  • 18
  • 127
  • 145
J.Tey
  • 225
  • 4
  • 18

1 Answers1

2

Simple.

Use

startActivityForResult(builder.build( ((Activity) view.getContext())), PLACE_PICKER_REQUEST);

instead of

startActivityForResult(builder.build(getApplicationContext()), PLACE_PICKER_REQUEST);
Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81