1

I am browsing the source code of GestureDetector in Android 5.0.1 through this link and trying to use some of the codes in this GestureDetector program in the MainActivity.onCreate method of an Android 5.0.1 project (just for testing purpose).

In GestureDetector's source, there is a line with the following code :

private static final int DOUBLE_TAP_MIN_TIME = ViewConfiguration.getDoubleTapMinTime();

However, when I type

ViewConfiguration.getDoubleTapMinTime();

in the onCreate method, I get the error

The method getDoubleTapMinTime() is undefined for the type 
 ViewConfiguration

From the reference page of ViewConfiguration (this link), I find that there seems NO getDoubleTapMinTime() method.

Similar pattern holds for getDoubleTapSlop(), getScaledDoubleTapTouchSlop() methods of ViewConfiguration, ViewConfiguration seems have NO such methods, but GestureDetector in Android 5.0.1 seems have used these methods (there seems a contradiction).

I have successfully used GestureDetector (not source, just used the binary) in another Android 5.0.1 project, I suspect whether the Android 5.0.1 GestureDetector source code link is valid or not (if the link is invalid, how to find the source of GestureDetector for Android 5.0.1 ?).

Does anyone know the source for this contradiction ?

Thanks for any suggestion.

user1129812
  • 2,859
  • 8
  • 32
  • 45
  • I am using Eclipse 4.4.2 with the ADT plugin to edit and compile the Android 5.0.1 project. I am sure the project has `target=android-21` in the "project.properties" file and `` in "AndroidManifest.xml" file . When I right-click on `ViewConfiguration` in the editor and open its declaration (i.e. its source code), I find that the ViewConfiguration's source contains the `getDoubleTapMinTime()` method. However, I get error when I have the `ViewConfiguration.getDoubleTapMinTime()` statement in the `onCreate` method. – user1129812 Jul 24 '15 at 13:55
  • Furthermore, when I type `ViewConfiguration`followed by a "." in a new line in the editor, the editor opens a pop-up menu listing the available methods of `ViewConfiguration`, but I find that there is no `getDoubleTapMinTime()` method in the available methods list while the `ViewConfiguration` source has the `getDoubleTapMinTime()` method. – user1129812 Jul 24 '15 at 14:19

1 Answers1

2

If you look at the source of ViewConfiguration closely, the method getDoubleTapMinTime() is annotated with @hide. It means that this method is something to be used to internally by Android and not for public consumption. The method is still present in the source code but javadoc for these methods are not generated. If you still want to use those methods, you need to use reflection. You can find more details on how to do that in this post by StarPinkER.

Community
  • 1
  • 1
Ganesh Kumar
  • 3,220
  • 1
  • 19
  • 27