32

I have this code

itemizedOverlay = new MyItemizedOverlay(drawable,this);
itemizedOverlay.setGestureDetector(new GestureDetector(new MyGestureDetecor()));

but new GestureDetector is marked as Deprecated in Eclipse.

I want to avoid the use of deprecated methods.

How could I fix this problem?

What is the non-deprecated form?

AndreaF
  • 11,975
  • 27
  • 102
  • 168

3 Answers3

66

Choose one of the other constructors. There are five defined constructors on GestureDetector. Two -- the ones not including a Context as the first parameter -- are marked as deprecated. You are using one of those.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
21

There are just two deprecated constructors. If you add the context to GestureDetector(context, listener) it's not deprecated.

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • how do i get context in class gesture detector – TechArcSri Mar 10 '14 at 12:23
  • @Sridhar There are several ways. `Activity` inherits from `Context`, so you can use `this` inside an Activity, or maybe you can use `getApplicationContext()`. See also the comments to @CommonsWare's answer. – Olaf Dietsche Mar 11 '14 at 21:04
-2

1 try add Context to your method: `

itemizedOverlay = new MyItemizedOverlay(drawable,this); itemizedOverlay.setGestureDetector(Context context new GestureDetector(new MyGestureDetecor()));`

2 if you already have call to class Context in your method try:

itemizedOverlay = new MyItemizedOverlay(drawable,this); itemizedOverlay.setGestureDetector(new GestureDetector(context new MyGestureDetecor()));

Youn Tivoli
  • 230
  • 2
  • 13