Skip to content

Commit 4407550

Browse files
committed
image v7.1.0
1 parent a8fe793 commit 4407550

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+273
-150
lines changed

docs/image/_includes/add-manual-appdescriptor.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ add the following to your manifest additions:
2323

2424
```xml
2525
<manifest android:installLocation="auto">
26+
<uses-sdk android:minSdkVersion="19" />
27+
2628
<uses-permission android:name="android.permission.INTERNET"/>
27-
29+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
30+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
31+
2832
<application>
33+
<service android:name="com.distriqt.extension.image.services.ScreenshotService"
34+
android:foregroundServiceType="mediaProjection"
35+
android:exported="false" />
36+
2937
<activity android:name="com.distriqt.core.auth.AuthorisationActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
3038
</application>
31-
39+
3240
</manifest>
3341
```
3442

docs/image/capturing-a-screenshot.md

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,55 @@
11
---
22
title: Capturing a Screenshot
3-
sidebar_label: Capturing a Screenshot
43
---
54

65

76
You can use this extension to capture a screenshot of your application as bitmap data and subsequently use that data as you require.
87

98
This is currently supported on iOS and Android API version 21 or higher.
109

11-
To capture a screenshot you simply call `captureScreenshot` and await completion.
10+
To capture a screenshot you simply call `captureScreenshot()` and await completion.
1211

1312
```actionscript
14-
var success:Boolean = Image.service.captureScreenshot();
13+
Image.service.captureScreenshot();
14+
```
15+
16+
`captureScreenshot()` may return `false` if the current platform is not supported or if a screenshot capture is currently in progress. You should avoid wherever possible capturing two screenshot simulataneously as this may have undesirable results.
17+
18+
19+
20+
21+
## Completion
22+
23+
You can either use a callback or events to handle the completion of the screenshot.
24+
25+
26+
### Callback
27+
28+
You can pass a callback function to the `captureScreenshot()` method:
29+
30+
```actionscript
31+
Image.service.captureScreenshot(
32+
function ( bitmap:BitmapData ):void
33+
{
34+
if (bitmap != null)
35+
{
36+
// bitmap will contain the bitmap data of the screenshot
37+
trace( "captureScreenshot: complete" );
38+
}
39+
else
40+
{
41+
trace( "captureScreenshot: an error occurred" );
42+
}
43+
}
44+
);
1545
```
1646

17-
`captureScreenshot` may return `false` if the current platform is not supported or if a screenshot capture is currently in progress. You should avoid wherever possible capturing two screenshot simulataneously as this may have undesirable results.
47+
The callback function must be of the format: `function ( bitmap:BitmapData ):void`.
48+
1849

50+
### Events
1951

20-
Completion is indicated by either a success event `ImageEvent.SCREENSHOT_COMPLETE` or an error `ImageEvent.SCREENSHOT_ERROR`.
52+
You can listen for a success event `ImageEvent.SCREENSHOT_COMPLETE` or an error `ImageEvent.SCREENSHOT_ERROR`.
2153

2254
```actionscript
2355
Image.service.addEventListener( ImageEvent.SCREENSHOT_COMPLETE, screenshot_completeHandler );
@@ -38,15 +70,43 @@ function screenshot_errorHandler( event:ImageEvent ):void
3870
```
3971

4072

41-
## iOS
73+
74+
## Platform Considerations
75+
76+
There are some differences between the platforms here.
77+
78+
79+
### iOS
4280

4381
On iOS your screenshot will be captured without any user interaction. It is not possible to get the current image of the status bar so only your application accessible content will be contained in the screenshot.
4482

4583

46-
## Android
84+
### Android
85+
86+
Since Android 26 we now have a method to capture the screen without user interaction and this is now the default operation of the extension. This approach won't capture the status or navigation bar elements similar to iOS however the operation will be much more seamless.
87+
88+
89+
If you wish to force the extension to use the older approach (with a media projection) you can pass `false` as the second parameter to the `captureScreenshot()` method, which will attempt to capture the full screen.
90+
91+
```actionscript
92+
Image.service.captureScreenshot( null, false );
93+
```
4794

48-
On Android, user permission is required to capture a screenshot. On calling `captureScreenshot` your user may be presented a permission dialog. If they accept then the screenshot will be captured and subsequent screenshots will not require interaction. If they deny the permission then the screenshot will fail with an error event and subsequent screenshot capture attempts will present the permission dialog again.
95+
#### Permission
96+
97+
On Android, user permission is required to capture a screenshot of the full screen. On calling `captureScreenshot()` your user may be presented a permission dialog. If they accept then the screenshot will be captured. If they deny the permission then the screenshot will fail with an error event and subsequent screenshot capture attempts will present the permission dialog again.
98+
99+
On older versions of the Android the following permission request is shown:
49100

50101
![](images/android-capturescreenshot-permission.png)
51102

52103

104+
With Android 26 and higher you are likely to see something like:
105+
106+
![](images/android-capturescreenshot-permission-26.png)
107+
108+
109+
On Android 36 and higher, you will have to get the user to select the "Share entire screen" option:
110+
111+
![](images/android-capturescreenshot-permission-36.png)
112+

docs/image/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### 2025.12.15 [v7.1.0]
2+
3+
```
4+
feat(android): add new capture screenshot functionality to capture application view without user interaction
5+
fix(android): correct issue with crash on newer android versions while using media projection to capture full screen (resolves https://github.com/distriqt/ANE-Image/issues/57, resolves https://github.com/distriqt/ANE-Image/issues/56)
6+
```
7+
18
### 2024.12.17 [v7.0.0]
29

310
```
90.3 KB
Loading
111 KB
Loading
-24.1 KB
Loading

docs/image/migrating-to-v6.0.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ Particularly due to all the file system changes in Android that require addition
1313

1414
Migration should be relatively straight forward, just replace the `Image.service.saveToCameraRoll()` with `CameraRollExtended.service.addBitmapData()`.
1515

16-
For more information see the documentation on the [CameraRollExtended](/docs/camerarollextended/adding-files.mdx).
16+
For more information see the documentation on the [CameraRollExtended](/docs/camerarollextended/adding-files).
1717

docs/image/migrating-to-v7.1.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Migrating to v7.1
3+
---
4+
5+
import Tabs from '@theme/Tabs'
6+
import TabItem from '@theme/TabItem'
7+
8+
This version makes some changes to the Android implementation to support capturing screenshots.
9+
10+
We have changed the default operation to use a new method that doesn't require user interaction for permissions but only captures the application window (similar to iOS).
11+
The previous method that captures the full screen including other applications is still available and has been improved to support the new requirements of using a foreground service but continues to require user permission via a system dialog.
12+
13+
This update requires some changes to the manifest additions, so you will need to update your application descriptor accordingly.
14+
15+
If you are using [`apm`](https://github.com/airsdk/apm) to manage your extensions you can update your application descriptor automatically by following the instructions below.
16+
17+
```
18+
apm update
19+
apm generate app-descriptor
20+
```
21+
22+
If you are managing your application descriptor manually you will need to ensure your manifest additions contains the following:
23+
24+
```xml
25+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
26+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
27+
28+
<application>
29+
<service android:name="com.distriqt.extension.image.services.ScreenshotService"
30+
android:foregroundServiceType="mediaProjection"
31+
android:exported="false" />
32+
33+
<activity android:name="com.distriqt.core.auth.AuthorisationActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
34+
</application>
35+
```
36+
37+
38+
As the default operation has changed to the new method that doesn't require user interaction, if you wish to continue to capture the full screen including other applications you will need to pass `false` to the second parameter of the `captureScreenshot()` method.
39+
40+
```actionscript
41+
Image.service.captureScreenshot( callback, false );
42+
```
43+

docs/image/saving-bitmapdata-to-the-camera-roll.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: Saving BitmapData to the Camera Roll
77
:::warning
88
This functionality has been deprecated and will be removed in an upcoming release.
99

10-
You should move to the [CameraRollExtended](/docs/camerarollextended/adding-files.mdx) extension for adding images to the Camera Roll.
10+
You should move to the [CameraRollExtended](/docs/camerarollextended/adding-files) extension for adding images to the Camera Roll.
1111

1212
Migration should be relatively straight forward, just replace the `Image.service.saveToCameraRoll()` with `CameraRollExtended.service.addBitmapData()`.
1313
:::

sidebars.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2063,7 +2063,12 @@ module.exports = {
20632063
},
20642064

20652065
{
2066-
Help: ["image/migrating-to-v5.2", "image/migrating-to-androidx"],
2066+
Help: [
2067+
"image/migrating-to-v7.1",
2068+
"image/migrating-to-v6.0",
2069+
"image/migrating-to-v5.2",
2070+
"image/migrating-to-androidx"
2071+
],
20672072
},
20682073
{
20692074
Other: [

0 commit comments

Comments
 (0)