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?
Asked
Active
Viewed 3,466 times
1 Answers
0
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.

Morshues
- 125
- 1
- 12
-
This puts a new activity over the top of the screen and doesn't actually let you screen record other apps. – CarCar Aug 19 '15 at 15:38
-
@CarCar 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. – Morshues Aug 19 '15 at 16:19
-
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 – CarCar Aug 19 '15 at 17:21
-
You can try to run a non-stop Service. It's work for me. – Morshues Aug 20 '15 at 03:31
-
Can you guys share code for the service?Especially about how to get Mediaprojection API in Service? – user2801184 Nov 23 '16 at 02:22
-
@user2801184 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. – Morshues Nov 23 '16 at 02:40
-
Notification notification = new NotificationCompat.Builder(this) .setContentTitle("Title") .setTicker("Title") .setContentText("App running") //.setSmallIcon(R.drawable.picture) .build(); startForeground(101, notification); Something like this? – user2801184 Nov 24 '16 at 01:44
-
Yes, you can try it. – Morshues Nov 24 '16 at 02:00
-
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. – user2801184 Nov 27 '16 at 02:24