Android Screenshot Share logo

Android Screenshot Share

Community
itgoyo
android-screenshot-share

Android 页面截图分享模式 — 隐藏指定控件后截图,通过分享弹窗发送到微信/QQ/保存相册

Overview

Publisheritgoyo
Repositoryhermes-skills
Skill nameandroid-screenshot-share
Stars
77
Forks
11
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by itgoyo on GitHub. Read the source before you install it.

Installation

Install the Android Screenshot Share AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/itgoyo/hermes-skills/tree/main/engineering/android-screenshot-share
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/itgoyo/hermes-skills.git /tmp/hermes-skills
mkdir -p .claude/skills
cp -r /tmp/hermes-skills/engineering/android-screenshot-share .claude/skills/android-screenshot-share
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Android Screenshot Share in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Android Screenshot Share on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Android Screenshot Share is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Android 页面截图分享

核心流程

点击分享按钮
  → 隐藏不想出现的控件(INVISIBLE,保留占位)
  → rootView.post { }  ← 等下一帧确保 visibility 已刷新
  → captureView(DecorView) → Bitmap
  → 恢复控件可见
  → 弹出分享弹窗传入 Bitmap

Activity 端代码模板

java
// import android.graphics.Bitmap;
// import android.graphics.Canvas;

private void takeScreenshotAndShare() {
    // 1. 隐藏不需要出现在截图中的控件(用 INVISIBLE 保留占位,避免布局抖动)
    backIV.setVisibility(View.INVISIBLE);
    shareIV.setVisibility(View.INVISIBLE);

    // 2. post 到下一帧,确保 visibility 变更已绘制
    View rootView = getWindow().getDecorView().getRootView();
    rootView.post(() -> {
        Bitmap screenshot = captureView(rootView);

        // 3. 恢复控件
        backIV.setVisibility(View.VISIBLE);
        shareIV.setVisibility(View.VISIBLE);

        if (screenshot == null) return;

        // 4. 弹出分享弹窗
        new CommonShareDialog.Builder(this)
                .setShareType(CommonShareDialog.TYPE_SHARE_IMG)
                .setShareBitmap(screenshot)
                .create()
                .show();
    });
}

private Bitmap captureView(View view) {
    try {
        Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        return null;
    }
}

为什么用 INVISIBLE 不用 GONE?
GONE 会触发 relayout,INVISIBLE 只触发 redraw,截图前后布局稳定不跳动。

CommonShareDialog 扩展(TYPE_SHARE_IMG 支持)

项目中 CommonShareDialog 的 TYPE_SHARE_IMG 分支默认为空,需要手动补全:

Builder 添加 setShareBitmap

java
// 字段
private Bitmap shareBitmap;

// Builder 方法
public Builder setShareBitmap(Bitmap bitmap) {
    this.shareBitmap = bitmap;
    return this;
}

// create() 里赋值
dialog.shareBitmap = shareBitmap;

handleWxShare — 微信图片分享

java
case TYPE_SHARE_IMG:
    if (shareBitmap != null) {
        try {
            AppHelper.wxShareBitmap(scene, shareBitmap);
        } catch (Exception e) {
            new CenterToast(mContext).show(
                mContext.getString(R.string.Please_install_WeChat_first), Toast.LENGTH_SHORT);
        }
    }
    break;

AppHelper.wxShareBitmap(int scene, Bitmap bitmap) 已封装好微信图片发送逻辑。

handleQQShare — QQ 图片分享

QQ SDK 图片分享需要本地文件路径,不能直接传 Bitmap:

java
private void qqShareBitmap(Bitmap bitmap) {
    try {
        // 1. 先保存到本地 cache(AppUtils2.saveBitmap 返回绝对路径)
        String imgPath = AppUtils2.saveBitmap(mContext, bitmap);
        if (imgPath == null || imgPath.isEmpty()) {
            new CenterToast(mContext).show("分享失败,图片保存出错", Toast.LENGTH_SHORT);
            return;
        }
        Activity topActivity = ActivityUtils.getTopActivity();
        if (topActivity == null) return;

        // 2. 通过 QQShare.SHARE_TO_QQ_TYPE_IMAGE 分享本地图片
        android.os.Bundle params = new android.os.Bundle();
        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_IMAGE);
        params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, imgPath);
        params.putString(QQShare.SHARE_TO_QQ_APP_NAME, topActivity.getString(R.string.app_name));
        Tencent.createInstance(BuildConfig.QQ_APP_ID, mContext)
                .shareToQQ(topActivity, params, new IUiListener() {
                    @Override public void onComplete(Object o) {}
                    @Override public void onError(UiError uiError) {}
                    @Override public void onCancel() {}
                });
    } catch (Exception e) {
        new CenterToast(mContext).show("QQ未安装或分享失败", Toast.LENGTH_SHORT);
    }
}

handleSaveOrCopy — 第四个按钮自适应

图片模式下第四个按钮(原"复制链接")改为"保存图片":

java
private void handleSaveOrCopy() {
    if (shareType == TYPE_SHARE_IMG && shareBitmap != null) {
        // 保存到相册
        AppUtils.insertPictureToSystem(
            shareBitmap,
            "report_" + System.currentTimeMillis(),
            () -> new CenterToast(mContext).show("保存成功", Toast.LENGTH_SHORT)
        );
    } else {
        // 复制链接(原有逻辑)
        AppUtils2.copyStr(mContext, shareUrl);
        new CenterToast(mContext).show(
            mContext.getString(R.string.Copy_links_successfully), Toast.LENGTH_SHORT);
    }
}

关键工具类(本项目)

工具方法用途
AppHelperwxShareBitmap(int scene, Bitmap)微信图片分享(已封装)
AppUtils2saveBitmap(Context, Bitmap) → String保存 Bitmap 到 cache,返回路径
com.lib.utils.AppUtilsinsertPictureToSystem(Bitmap, String, Runnable)保存 Bitmap 到系统相册
ActivityUtilsgetTopActivity()获取当前顶部 Activity(QQ 分享需要)

陷阱

  • AppUtils2.saveBitmap 只有两参数版本 (Context, Bitmap),没有带文件名的三参数版本,不要传文件名
  • captureView 截取的是 DecorView(包含状态栏),如果只想截内容区域,改用 findViewById(android.R.id.content) 或自定义根 View
  • 微信图片分享 Bitmap 大小有上限(约 25MB),超大截图需缩放
  • QQ SDK 图片分享不支持直接传 Bitmap,必须先落盘拿到本地路径

Frequently asked questions

What does the Android Screenshot Share AI skill do?

Android 页面截图分享模式 — 隐藏指定控件后截图,通过分享弹窗发送到微信/QQ/保存相册

Why use Android Screenshot Share on TypingMind?

Because you install it once and use it with any model. Android Screenshot Share is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Android Screenshot Share in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/itgoyo/hermes-skills/tree/main/engineering/android-screenshot-share. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Android Screenshot Share?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Android Screenshot Share?

As many as you like. As long as a model supports skills, you can use Android Screenshot Share with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Android Screenshot Share AI skill free?

It is published on GitHub by itgoyo. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇