I started to work with Lollipop & Media.Projection class to implement a screen sharing app. The demo project from Google is quite good enough for me to understand this new feature of Lollipop. But then I found it's hard to make the screen capture goes background since all the time when Home or Back button are pressed, the surface activity is destroyed hence the capturing thread will no longer work. Is there any hint on this situation?
Screen capture with background service
This problem may cause by your application is finished by LMK(low memory killer).
You can pin a fixed notification by using "startForeground" on custom Service to avoid LMK.
This puts a new activity over the top of the screen and doesn't actually let you screen record other apps. –
Neurath
@Neurath Sorry, the last answer is wrong so I corrected it. However
Media.Projection
has full ability can record all screen of phone, including graphics lock. –
Jahnke its ok.. i was hoping you would come back and tell me I was wrong :( I have same problem as original user and tried your solution but didn't work –
Neurath
You can try to run a non-stop Service. It's work for me. –
Jahnke
Can you guys share code for the service?Especially about how to get Mediaprojection API in Service? –
Abortion
@Abortion the old answer is wrong, please check the new answer. you can make your own service and 'startForeground' in service to make an undead background application. –
Jahnke
Notification notification = new NotificationCompat.Builder(this) .setContentTitle("Title") .setTicker("Title") .setContentText("App running") //.setSmallIcon(R.drawable.picture) .build(); startForeground(101, notification); Something like this? –
Abortion
Yes, you can try it. –
Jahnke
Did not help :(. the moment I press home button. It stops capturing the screen. Can you please suggest me something else? I am using C#(Xamarin ndroid). it is pretty critical. Any sample working code is appreciated. –
Abortion
© 2022 - 2024 — McMap. All rights reserved.