1

Is there a shortcut / quick way of opening the sources of Android SDK classes in Android Studio without using a reference in code of the class looked for?

  • When you start typing a class name in code you can auto-complete it and when you use CTRL+B (go to definition) on the name it opens the corresponding source file.

  • However, when you want to look at a class currently not in your code you cannot use this shortcut. As a workaround, I type the class name in some source file just to use the go-to-definition shortcut and then remove it again. This is of course not nice and could be faster.

Other questions like How to browse android SDK sources in Android studio 2.0 only seem to be about making Android Studio aware of the SDK sources in general.

In general with IntelliJ

As pointed out by Enzokie, this problem might apply to IntelliJ in general. The question then generalises to whether one can conveniently open source files the IDE "is aware of" (such as SDKs, libraries). In the case of the Android SDK there is a separate settings entry under Settings -> System settings -> Android SDK which makes Android Studio "aware" of the SDK (and its source location). I am not sure whether the IDE is aware of other sources in the same way, when the sources are being made aware with a different setting.

Community
  • 1
  • 1
user905686
  • 4,491
  • 8
  • 39
  • 60
  • 1
    Actually this question is generally about for IntelliJ even if your concern is Android studio. – Enzokie Oct 23 '16 at 13:49

1 Answers1

1
  • Press Ctrl+N to navigate to a class in project by specifying its name in a pop-up dialog box.

  • Press Press Ctrl+Shift+N to navigate to a file in the project in the same way.

Note: Pressing this key combination twice will also include non-project classes / files.

For example you want to see HttpServletRequest sources:

enter image description here

DimaSan
  • 12,264
  • 11
  • 65
  • 75