[APP] Floating Example

Search This thread

EatHeat

Inactive Recognized Developer
Jan 5, 2013
946
1,517
28
Calcutta
www.facebook.com
There are a lot of apps coming which float above other apps like Chatheads for Facebook. So I made an example app showing how they work.

It is basically a view in a WindowManager which is inflated in a Service. With a few more tweaks, it can be made to change positions on the fly.

I made this for API 10+ but it should work with lower versions just fine.

Here is how it looks:

M4FhK8q.png


TXq0i26.png


kE7gxDZ.jpg

This is just an example. The possibilites are countless.

Hope it helps developers create other apps like Floating Notifications and such.

Full sources can be found on my Github here.

Sample app can be found here.

Regards.


-----------------------------------

Featured on Portal:

http://www.xda-developers.com/android/use-windowmanager-to-create-floating-apps/
 
Last edited:

misternox

Member
Jul 8, 2009
32
2
This is real good, Are you planning for futher devlopment?

Verstuurd vanaf mijn GT-I9505 met Tapatalk 4
 

EatHeat

Inactive Recognized Developer
Jan 5, 2013
946
1,517
28
Calcutta
www.facebook.com

Akshay (Aky)

Senior Member
Jul 10, 2012
925
723
Pune
Great work.
I had an wish to make an floating apps, using your library this would be surely accomplished.

Sent from my GT-I9300 using XDA Premium 4 mobile app
 

arashtarafar

Senior Member
Sep 26, 2010
176
43
Maybe we can expect some multi-window work from you?
That would be awesome... and after I make myself comfortable with android programming, you may count me in, also!
 
  • Like
Reactions: misternox

Dr.Alexander_Breen

Senior Member
Jun 17, 2012
439
1,072
Basically if I press the circle the poweramp app will open in it. That is what I wish :)

Sent from my myTouch 4g using xda app-developers app

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.
 
Last edited:
  • Like
Reactions: N_otori0us_

EatHeat

Inactive Recognized Developer
Jan 5, 2013
946
1,517
28
Calcutta
www.facebook.com
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. :good:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    There are a lot of apps coming which float above other apps like Chatheads for Facebook. So I made an example app showing how they work.

    It is basically a view in a WindowManager which is inflated in a Service. With a few more tweaks, it can be made to change positions on the fly.

    I made this for API 10+ but it should work with lower versions just fine.

    Here is how it looks:


    This is just an example. The possibilites are countless.

    Hope it helps developers create other apps like Floating Notifications and such.

    Full sources can be found on my Github here.

    Sample app can be found here.

    Regards.


    -----------------------------------

    Featured on Portal:

    http://www.xda-developers.com/android/use-windowmanager-to-create-floating-apps/
    1
    Maybe we can expect some multi-window work from you?
    That would be awesome... and after I make myself comfortable with android programming, you may count me in, also!
    1
    Basically if I press the circle the poweramp app will open in it. That is what I wish :)

    Sent from my myTouch 4g using xda app-developers app

    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.