Closed JakeWharton closed 8 years ago
The library should have a reference to the Activity in order to accomplish this. We need to call startActivityForResult
once to get a permission.
startActivityForResult(
mMediaProjectionManager.createScreenCaptureIntent(),
REQUEST_MEDIA_PROJECTION);
How do you think it should be done? The first thing I thought was to have a method like initialize(Activity this)
and make the caller Activity
override onActivityResult
and call our helper method again like telescopeLayout.handleActivityResult(...)
Views don't have direct access to Activity's. If we don't want to do this, we may re-structure the library to do it.
Yeah, TelescopeLayout
will need a reference to an activity and will need to expose a method for handling the activity result. I started working on this a while back but couldn't figure out the media projection part of it. Not sure how to turn any of that into a screenshot.
My WIP API was this:
public void setNativeScreenshotEnabled(Activity activity) { }
public void setNativeScreenshotDisabled() { }
public void onActivityResult(int requestCode, int resultCode, Intent data) { }
Should probably change the last one to return a boolean
of whether or not the result was handled.
@mattprecious What about just setNativeScreenshotEnabled(MediaProjection projection)
and leave it as the Activity's responsibility to get a projection?
That works, but it means the app would need to front-load the request for the permission instead of at the time of the screenshot request.
This library is an aar, right? You could embed an activity with a completely transparent theme which would be started and could handle the whole intent interaction dance if native capture was enabled.
Oooooh.... I'll look into that.
@mattprecious My thinking is that it isn't a big deal because it is a (hopefully) one-time user-facing prompt and only for debug builds (UX isn't crucial).
@jakewharton Cool idea; I'll give that a try as well. :-)
On Fri, Oct 23, 2015, 12:07 PM Matthew Precious notifications@github.com wrote:
Oooooh.... I'll look into that.
— Reply to this email directly or view it on GitHub https://github.com/mattprecious/telescope/issues/13#issuecomment-150665475 .
My hesitation with doing it up front is that we use this for our company-wide internal builds, which includes many people who aren't Android developers. Without any context they aren't going to know why they're being asked for such a thing and will likely deny it.
http://developer.android.com/about/versions/android-5.0.html#ScreenCapture