3

I am attempting to create a custom Media Controller by duplicating the source and providing my own layout. The final component is a substitute for PolicyManager.makeNewWindow(mContext); The PolicyManager class is an internal class and I can not seem to find a way to get a new Window. The documentation suggests new Window(mContext) but eclipse complains that it 'Cannot instantiate the type Window'. Any ideas?

Larry McKenzie
  • 3,253
  • 25
  • 22

1 Answers1

0

Unless you use the NDK to access private implementations, you cannot actually create a Window. I have done exactly what you are trying with an embedded system, but it is not safe to do for a general purpose app (the underlying implementations have changed and will change again).

Regardless of whether you are using a SurfaceView or TextureView for the MediaPlayer, you should be able to a achieve a similar effect with a regular old transparent custom View. The separate Window shouldn't be necessary. It won't be as easy as copying Android's MediaController code, but it shouldn't be too complicated.

Also, if all you want is a different layout and not a drastic change in functionality, have a look at these two links (the second refers to the first, but it adds commentary & an example project).

Community
  • 1
  • 1
Dave
  • 4,282
  • 2
  • 19
  • 24
  • No, NativeActivity steals the whole surface from the Window, causing the window to not draw at all. You need to create a separate window if you need to draw anything at that point. – Glenn Maynard Feb 11 '16 at 23:49
  • I don't see what NativeActivity has to do with any of this. I'm also not sure what part of my answer you are saying "no" to. Perhaps you think NativeActivity is the only way to use native code? – Dave Feb 12 '16 at 12:37