android - how to let a floating touch on all app -


I'm trying to create a clickable-image that stays at the top of all apps and desktops, such as Facebook Messenger

And this is my code

  extension of the Public Class FloatService service {Private WindowManager windowManager; Private image view image; @ Ivoride Public Ibidinder On Bind (Intent of Intent) {Return Null; } @ Override Public Wide On Crack () {Super. Connet (); WindowManager = (WindowManager) getSystemService (WINDOW_SERVICE); ImageBtn = new image view (this); ImageBtn.setImageResource (R.drawable.ic_launcher); WindowManager.LayoutParams params = New Window Manager. LayoutParamus (Window Manager, LayoutPam .WRAP_CONTENT, Window Manager, LayoutPem.WRAP_CONTENT, Window Manager, LayoutPreferenceTep_phone, WindowManager, LayoutParams.flag_ONfoxable, PixelFormat.transLuissant); Params.gravity = Gravity Tap | Gravity.LEFT; Params.x = 0; params.y = 100; WindowManager.addView (Image Batten, Parameters); } @ Override Public Watch OnDestoy () {Super. One day (); If (imageBtn! = Null) windowManager.removeView (imageBtn); }}   

and

  & lt; Usage-permission Android: name = "android.permission.SYSTEM_ALERT_WINDOW" />   

There are two buttons in my activity, one of the "start services", and the other is "stop service", I click on "start service", it's a clickable The image creates, so it's all right. But when I switch to another app or leave this app, the clickable-image will disappear, as long as I do not open my app.

Thanks for the help

This is because of the low memory problem When you exit your app, your service is destroyed

Therefore 1. You can pass START_STICKY to the service on the internet commencing ()

2.You have a foreground You can start the service as a service

Do not kill Android completely forfood service completely.

This can help you >

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -