tencent cloud

Tencent Cloud Super App as a Service

Screenshot, Screen Recording Events, and Adding Watermarks

Download
Focus Mode
Font Size
Last updated: 2025-07-04 17:33:29
Use MediaObserveUtil to listen for screenshot events:
MediaObserveUtil.getInstance().addListener(new OnScreenShotListener() {
@Override
public void onScreenShot(String imagePath) {
// Handle screenshot events
}
});
Set FLAG_SECURE in the Activity to disable screenshots:
activity.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
);
Use the IScreenRecord to listen for screen recording status:
public interface IScreenRecord {
int RECORD_STATUS_HIDDEN = 0;
int RECORD_STATUS_SHOW = 1;
int RECORD_STATUS_RECORDING = 2;
void onScreenCaptureStarted();
void onScreenCapturePaused();
void onScreenCaptureResumed();
void onScreenCaptureStopped(int reason);
}
Add watermarks:
// 1. Image watermark
BitmapUtils.addWatermark(
watermark, // Watermark image
image, // Full size image
srcImageWidth, // Full size image width
offsetX, // X axis offset
offsetY, // Y axis offset
addInLeft, // Whether it is on the left
orientation // Rotation angle
);

// 2. Text watermark
BitmapUtils.addWatermarkWithText(
watermark, // Watermark image
image, // Full size image
srcImageWidth, // Full size image width
text, // Watermark text
offsetX, // X axis offset
offsetY, // Y axis offset
addInLeft, // Whether it is on the left
orientation // Rotation angle
);

// 3. Video watermark
// Set video watermark parameters via TXJSAdapterConstants
PUSHER_KEY_WATERMARK_IMAGE // Watermark image
PUSHER_KEY_WATERMARK_LEFT // Watermark X position (percentage)
PUSHER_KEY_WATERMARK_TOP // Watermark Y position (percentage)
PUSHER_KEY_WATERMARK_WIDTH // Watermark width (percentage)
Implement the IWaterMakerProxy API to create a custom watermark view:
// Implement the IWaterMakerProxy API to create a custom watermark view
@ProxyService(proxy = IWaterMakerProxy.class)
public class MiniWaterMarkProxy implements IWaterMakerProxy {
@Override
public View createWatermarkView(Context context, LayoutParams layoutParams,
MiniAppInfo finAppInfo, JSONObject jsonObject) {
TextView textView = new TextView(context);
textView.setText("TCMPP Auth");
textView.setTextColor(Color.RED);
textView.setTextSize(30);
// Set watermark position and size
layoutParams.topMargin = 600;
layoutParams.width = 1000;
layoutParams.height = 1000;
layoutParams.leftMargin = 100;
return textView;
}
}



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback