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.

Share:
21,304
AndreaF
Author by

AndreaF

Updated on March 04, 2020

Comments

  • AndreaF
    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
    ThE uSeFuL almost 11 years
    @CommonsWare what should I pass as context?
  • CommonsWare
    CommonsWare almost 11 years
    @ThEuSeFuL: I would assume that your Activity is handy and a likely candidate.
  • ThE uSeFuL
    ThE uSeFuL almost 11 years
    @CommonsWare I just figured it out and now its working I think. Used getBaseContext()
  • TechArcSri
    TechArcSri about 10 years
    how do i get context in class gesture detector
  • Olaf Dietsche
    Olaf Dietsche about 10 years
    @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.