【问题标题】:Take a screeshot of the screen via android phone [duplicate]通过android手机截取屏幕截图[重复]
【发布时间】:2014-03-18 00:06:12
【问题描述】:

我如何通过android进行屏幕截图。我的意思是我想编写一个程序来制作屏幕截图。感谢任何链接,谢谢大家

【问题讨论】:

  • 属于您的应用还是属于任何应用?
  • 什么??你能给我详细信息
  • 您想为自己的应用或任何应用截屏吗?
  • 手机上运行的任何应用
  • 谢谢帕玛,是的,它似乎被复制了

标签: android


【解决方案1】:

这并不像您希望的那样容易。出于安全原因,没有官方 API。

以下是您的选择:

  • 使用screencap命令行工具:需要root权限,并非所有手机都安装
  • 获取帧缓冲区:需要 root
  • 使用 android-screenshot-library:需要 adb 连接才能启动

【讨论】:

    【解决方案2】:

    我用这段代码截图MY APP(其他应用不能截图)

    @SuppressLint("SimpleDateFormat")
    protected final static boolean shoot
    (final View v, final String appName)
    {
        // Get the bitmap from the view
        v.setDrawingCacheEnabled(true);
    
        boolean isOK = false;
    
        final Bitmap bmp = v.getDrawingCache();
    
        final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd@HHmmss");
        final Calendar cal = Calendar.getInstance();
    
        // Set file properties
        fileJPG = appName + "_" + sdf.format(cal.getTime());
    
        /*
        Create a path where we will place our picture in the user's public
        pictures directory. Note that you should be careful about what you
        place here, since the user often manages these files.
        For pictures and other media owned by the application, consider
        Context.getExternalMediaDir().
        */
        final File path =
            Environment.getExternalStoragePublicDirectory
            (
                Environment.DIRECTORY_DCIM + "/Your_App_Name/"
            );
    
        // Make sure the Pictures directory exists.
        if(!path.exists())
        {
            path.mkdirs();
        }
    
        final File file = new File(path, fileJPG + ".jpg");
    
        try
        {
            final FileOutputStream fos = new FileOutputStream(file);
            final BufferedOutputStream bos =
                new BufferedOutputStream(fos, 8192);
    
            bmp.compress(CompressFormat.JPEG, 85, bos);
    
            bos.flush();
            bos.close();
    
            fileJPG = file.getPath();
            isOK = true;
        }
        catch (final IOException e)
        {
            e.printStackTrace();
        }
        return isOK;
    }
    

    【讨论】:

    • 我刚刚下载了一个程序,可以截取任何应用程序的屏幕截图。如何可能
    • 安卓市场上应用名称的简单截图
    • 你的手机是ROOTED吗?
    • noo 没有root
    • 看看this linkthis one能否解决你的问题。
    猜你喜欢
    • 1970-01-01
    • 2021-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多