GestureDetector Deprecated Issue
21,304
Solution 1
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.
Solution 2
There are just two deprecated constructors. If you add the context to GestureDetector(context, listener) it's not deprecated.
Author by
AndreaF
Updated on March 04, 2020Comments
-
AndreaF about 4 years
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?
-
ThE uSeFuL almost 11 years@CommonsWare what should I pass as context?
-
CommonsWare almost 11 years@ThEuSeFuL: I would assume that your
Activity
is handy and a likely candidate. -
ThE uSeFuL almost 11 years@CommonsWare I just figured it out and now its working I think. Used getBaseContext()
-
TechArcSri about 10 yearshow do i get context in class gesture detector
-
Olaf Dietsche about 10 years@Sridhar There are several ways.
Activity
inherits fromContext
, so you can usethis
inside an Activity, or maybe you can usegetApplicationContext()
. See also the comments to @CommonsWare's answer.