0

I've seen this and several other similar questions, and I know the problem and what people are saying is the solution: to use the youtube API, you should use your application context rather than the activity context because of, seemingly, a bug in the youtube API. However, the context must implement OnInitializedListener, and only my activity does that--not my applicationContext.

When I use the line youTubePlayerView.initialize(API_KEY, getApplicationContext()); I get the error Wrong 2nd argument type. Found android.content.Context, required: 'com.google.android.youtube.player.YouTubePlayer.OnInitializedListener'.

How can I fix this memory leak?

Community
  • 1
  • 1
Jameson
  • 4,198
  • 4
  • 17
  • 31

1 Answers1

0

Create a class CustomApplication extends Application implements OnInitializedListener. Then pass the custom application as an argument in method initialize.
Hope it helps.

Huy Duong Tu
  • 7,798
  • 5
  • 25
  • 46