简体   繁体   中英

Small app on top of the screen

I've got Sony Xperia Smartphone and there is a Sony feature - Small Apps (screen below), which are always on top of the screen or they minimalise to small square on right side. Very similar functionality have Facebook Messanger. Anybody knows how to do application like this? It is kind of service with GUI or what? There is any library from Google or it is only Sony and Facebook APIs? I even have no idea how to look for it in the Internet, so I will be grateful for some keywords or example.

小型应用

Best Regards,

Cookie

it's a UI without activity. I'm pretty sure any network/disk operations on it gets delegated to a Service, but that depends on how you organise your app.

the basics for it is:

  • you need the permission android.permission.SYSTEM_ALERT_WINDOW on your manifest
  • get the WindowManager with getSystemService(WINDOW_SERVICE)
  • build the view you want to show with context.getApplicationContext() (if you try an activity, service or broadcast receiver context it won't work).
  • and call addView(View, LayoutParams) to add it to the screen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM