0

For assets need to use getAssets() method, but this method requires the Context.

I found some interest method getResourceAsStream().

Using:

private InputStream openFile(String filename) throws IOException {
   return getClass().getClassLoader().getResourceAsStream(filename);
}

Next, how to convert InputStream to audio format?

Kasım Özdemir
  • 5,414
  • 3
  • 18
  • 35
Dyno Cris
  • 1,823
  • 1
  • 11
  • 20
  • 1
    `getResourceAsStream()` is not for either Android resources or assets. Beyond that, what do you mean by "convert InputStream to audio format"? – CommonsWare Apr 21 '20 at 19:37
  • then for what? What are other ways to play sound without Context? – Dyno Cris Apr 21 '20 at 19:39
  • 1
    Whatever caused your code to run gave you a `Context`. Or your dependency inversion framework (Dagger, Koin, etc.) can give you a `Context`. Why is using a `Context` is a problem? – CommonsWare Apr 21 '20 at 19:52
  • @CommonsWare, it's because it's not my app. I disassembled it using apktool. The Class where I want to play sound has no Context. – Dyno Cris Apr 22 '20 at 09:05

0 Answers0