screenshotty icon indicating copy to clipboard operation
screenshotty copied to clipboard

Cannot get screenshot in background activity

Open sheng-di opened this issue 4 years ago • 6 comments

screenshotManager = new ScreenshotManagerBuilder(getActivity())
        .withPermissionRequestCode(REQUEST_SCREENSHOT_PERMISSION)
        .build();
ScreenshotResult screenshotResult = screenshotManager.makeScreenshot();
// following code seems no usage
screenshotResult.observe((screenshot) -> {
    // WON'T GET THE SCREENSHOT 
    return Unit.INSTANCE;
}, (throwable -> {
    return Unit.INSTANCE;
}));

If the activity is in foreground, it performs well. However, when broadcasting the activity, and put this code in receiver's callback, I cannot get the screenshot.

sheng-di avatar Mar 15 '20 13:03 sheng-di

How can I use MediaProjection explicitly?

sheng-di avatar Mar 15 '20 13:03 sheng-di

can you guide me, I don't know Kotlin exactly so I don't know exactly how you get a screenshot object from "it"? please help me

abossjamlai avatar Mar 17 '20 20:03 abossjamlai

can you guide me, I don't know Kotlin exactly so I don't know exactly how you get a screenshot object from "it"? please help me

Apologize for the late reply. I post my code here: Screen Paste

I am just an android beginner, and inadvertently found that screenshotResult.observe method can obtain an screenshot object, which can be cast to ScreenshotBitmap, and the ScreenshotBitmap object has the getBitmap method.

Currently, I want to get the screenshot after clicking a notification. However, it doesn't work. Would you clone and check it for me?Any help will be appreciated. Thanks.

It's an interesting application which can float texts or pictures on the screen. I wanted to increase the productivity of my phone, but I didn't find a similar application, so I studied Android and made a simple version. Hope you can answer my confusion.

sheng-di avatar Apr 02 '20 16:04 sheng-di

can you guide me, I don't know Kotlin exactly so I don't know exactly how you get a screenshot object from "it"? please help me

Apologize for the late reply. I post my code here: Screen Paste

I am just an android beginner, and inadvertently found that screenshotResult.observe method can obtain an screenshot object, which can be cast to ScreenshotBitmap, and the ScreenshotBitmap object has the getBitmap method.

Currently, I want to get the screenshot after clicking a notification. However, it doesn't work. Would you clone and check it for me?Any help will be appreciated. Thanks.

It's an interesting application which can float texts or pictures on the screen. �I wanted to increase the productivity of my phone, but I didn't find a similar application, so I studied Android and made a simple version. Hope you can answer my confusion.

Hi! Did I get you correct that the issue is that you don't get broadcast during clicking to notification? But not that screenshotty doesn't make a screenshot?

xzaleksey avatar Apr 28 '20 08:04 xzaleksey

can you guide me, I don't know Kotlin exactly so I don't know exactly how you get a screenshot object from "it"? please help me

Apologize for the late reply. I post my code here: Screen Paste I am just an android beginner, and inadvertently found that screenshotResult.observe method can obtain an screenshot object, which can be cast to ScreenshotBitmap, and the ScreenshotBitmap object has the getBitmap method. Currently, I want to get the screenshot after clicking a notification. However, it doesn't work. Would you clone and check it for me?Any help will be appreciated. Thanks. It's an interesting application which can float texts or pictures on the screen. �I wanted to increase the productivity of my phone, but I didn't find a similar application, so I studied Android and made a simple version. Hope you can answer my confusion.

Hi! Did I get you correct that the issue is that you don't get broadcast during clicking to notification? But not that screenshotty doesn't make a screenshot?

It seems to be so. If the application runs in background, it fails

sheng-di avatar Apr 28 '20 09:04 sheng-di

Is this supported now?

albert17 avatar Apr 30 '23 19:04 albert17