Closed pourya0111 closed 6 years ago
Because the service expects MediaProjection permission to be granted before initialising the recording. Check Fab onclick and Activity Result methods in MainActivity for how it is done
isnt that one time grant permission enough??i mean every time we want call it from another class we have to check for permission?
Unlike the other runtime permission, MediaProjection is a service and you have to "request" for it every time you want to use it. When the user clicks "Dont show again" checkbox in the permission dialog, the MediaProjection service just arbitrarily provides intent data back which is needed to get the service and start recording.
Tl;dr: yes. you need to request the MediaProjection service every time which will in turn request user's permission.
lets say im in a class that doesnt extends appcompatactivity then hoe to check for that permission?? just like the fab done on the main activity the only difference is that my activity extends recycleview thanks in advance
as i searched and aknowleged we cant startactivityforresult from service or any broadcast receiver this means we cant have a startrecording directly in homescreen on shortcutoverlay?? but i saw simmilar apps doing this right in home screen(outside the app) whats the trick can we do that vijay?
@pourya0111 sorry for late reply. Yes you need a activity to perform it. The work around being, create a new activity with a transparent theme set/no content view and then create MediaRecorder service instance, handle it and at the end, finish()
to make sure the activity is not added to the stack.
im so sorry for annoyance vijay i didnt get what you mean by creating a nonthem activity
my nees is very simple and that is a feature to start recording without opening the app and pass activityresult to recorder servivce in background without the app beinged open
a good example is a floating control just like the one exist in app with a difference that you cand add it to hom screen then close app and whenever you want a screen capture simply pressing start in floating...
is it possible or not??
another usage can be to set a alarmmanager for triggering screen record in a spicified time right now i wrote a class for firing a brodcast to do aomething but dont know how pass start record to it... and need to know how to start it without being in activity somehow or maybe som tricky ways i know its possible because some apps has ablity to start without the need to being in activity e.g telecine
Well, I understood what you need. Lets break the problem now. You need a activity to do startactivityforresult but also the user should not know of any activity being opened. So we gonna create a activity which will act like a proxy to get the required data and pass it on to the service.
I have written a sample project here for you which does that.
Note: Please read the comments in the code.
Closing issue. I believe your issue is solved.
hey there why app force closes when i try to call intent.setaction(const.SCREEN_RECORDING_START) from another activity??