自用
Android Java Program
import android.app.Activity;
import android.content.Context;
import android.view.WindowManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
public class DoNotScreenFire extends Activity {
? ?// Request permission to use the window
? ?android_request_window_permission();
? ?// Set a timer to check every 5 minutes
? ?setTimer(5 * 60 * 1000);
? ?// Check if the user has clicked the confirmation button
? ?if (checkConfirmation()) {
? ? ? ?// Do nothing
? ?} else {
? ? ? ?// Close the phone screen
? ? ? ?closeScreen();
? ? ? ?// If the phone screen cannot be closed, generate a full-screen black image
? ? ? ?if (!closeScreen()) {
? ? ? ? ? ?generateFullScreenBlackImage();
? ? ? ? ? ?// Show the full-screen black image using a window
? ? ? ? ? ?showWindow();
? ? ? ?}
? ?}
? ?// Function to check if the user has clicked the confirmation button
? ?private boolean checkConfirmation() {
? ? ? ?// Code to check if the user has clicked the confirmation button
? ? ? ?// Return true if the user has clicked the confirmation button
? ? ? ?// Return false if the user has not clicked the confirmation button
? ?}
? ?// Function to close the phone screen
? ?private void closeScreen() {
? ? ? ?// Code to close the phone screen
? ?}
? ?// Function to generate a full-screen black image
? ?private void generateFullScreenBlackImage() {
? ? ? ?// Code to generate a full-screen black image
? ? ? ?// Adapted to the device's resolution
? ? ? ?WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
? ? ? ?int width = windowManager.getDefaultDisplay().getWidth();
? ? ? ?int height = windowManager.getDefaultDisplay().getHeight();
? ? ? ?Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
? ? ? ?Canvas canvas = new Canvas(bitmap);
? ? ? ?canvas.drawColor(0xFF000000);
? ?}
? ?// Function to show the full-screen black image using a window
? ?private void showWindow() {
? ? ? ?// Code to show the full-screen black image using a window
? ?}
}