Originally Posted by Dr.Alexander_Breen
You can try out my Floating Music Widget. It works with PowerAmp.(if not, PM me and I'll make it work).
To the app author - this isn't really a good example. It doesn't explain what does methods of WindowManager do, why we need to call them. It doesn't explain the LayoutParams parameters. For example, you could say that different types of windows allow different visibility - for example, that TYPE_PHONE is OK for most of floating windows, and TYPE_SYSTEM_ERROR can be used for something that has to overlay everything, even status bar and lockscreen.
Your code, however, also has flaws. For example, unused constant. Programming newbie can think that it is necessary to make floating windows. And handling general Exception is a bad practice. Newbie can think that floating window can throw ANY exception. Instead, you should catch IllegalArgumentException and explain the user that it is because sometimes View gets detached from Window BEFORE touch event handling occurs.
Yes, you are correct about the unused constant. I was going to add a feature of putting it into the status bar by preference to be accessed from there, but in the end decided against it. Hence, the unused constant.
As for the explaining part for newbies, I didn't think it necessary since its not at all hard. Reading the docs would be enough to handle this.
Anyways thanks for pointing this out.
Get Pie on any device.
Theme the Themer.
All my work can be found here.