bolteu / screenshotty

A library for programatically capturing screenshots on Android
MIT License
265 stars 41 forks source link

Cannot get screenshot in background activity #9

Open sheng-di opened 4 years ago

sheng-di commented 4 years ago
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 commented 4 years ago

How can I use MediaProjection explicitly?

abossjamlai commented 4 years ago

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

sheng-di commented 4 years ago

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.

xzaleksey commented 4 years ago

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?

sheng-di commented 4 years ago

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

albert17 commented 1 year ago

Is this supported now?