如何利用Android的屏幕没有扎根的手机本身的活动视图的屏幕截图? [英] how to take screen shot of android screen not own activity view without rooted phone?

查看:128
本文介绍了如何利用Android的屏幕没有扎根的手机本身的活动视图的屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了code。

public static void loadBitmapFromView(Context context, View v) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics(); 
    v.measure(MeasureSpec.makeMeasureSpec(dm.widthPixels, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(dm.heightPixels, MeasureSpec.EXACTLY));
    v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
    Bitmap returnedBitmap = Bitmap.createBitmap(v.getMeasuredWidth(),
            v.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(returnedBitmap);
    v.draw(c);

    takeScreen(returnedBitmap);
}

public static void takeScreen(Bitmap bitmap) {
    //Bitmap bitmap = ImageUtils.loadBitmapFromView(this, view); //get Bitmap from the view
    String mPath = Environment.getExternalStorageDirectory() + File.separator + "screen_" + System.currentTimeMillis() + ".jpeg";
    File imageFile = new File(mPath);

    try {
        OutputStream fout = new FileOutputStream(imageFile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);
        fout.flush();
        fout.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

其中的观点是

View v1 = getWindow().getDecorView().findViewById(android.R.id.content).getRootView();

但是,这需要我们的应用程序的当前活动的屏幕截图。
我想我的Andr​​oid当前屏幕不是我自己目前的activity.Please提供解决方案的屏幕。

But this take our application's current activity screen shot. I want to screen of my android current screen not my own current activity.Please provide solution.

推荐答案

既然你证明,已经有一个第三方应用程序(而不是三星应用程序),可以采取任何应用的屏幕截图上的一些三星设备。

Since you proved that there was already a third party app (not a samsung app) that can take screenshots of any app on some Samsung devices.

我建议你试试:
http://developer.samsung.com/home.do

如果没有什么明显的在他们关于采取截图的SDK。我建议你​​看看三星的AllShare / Miracast的SDK 。的AllShare是三星自家的Miracast的扩展。这就像DNLA(如果你知道DNLA是什么)。它允许开发人员/或以无线方式投射自己的电视屏幕上(支持协议)。

If there is nothing obvious in their sdks about taking screenshots. I'd suggest you take a look at the Samsung AllShare/Miracast SDK. AllShare is Samsung's own extension of MiraCast. It's like DNLA (if you know what DNLA is). It allows a developer/or a user to project wirelessly their screen on a TV (that supports the protocol).

如果说搜索不会去任何地方,看看在 s.pen SDK 。并尝试看看他们是否暴露的方式来承担第三方开发商与三星笔截图。现在我知道你的三星手机没有一支笔,但由于有很多的TouchWiz共享三星设备之间code。如果您发现该SPEN用来采取截图暴露的公共钩,你可以找到一个在不具备SPEN三星设备。

If that search doesn't go anywhere, take a look at the s.pen sdk. And try to see if they exposed a way to take screenshots for third party developers with the Samsung pen. Now I realize your samsung phone doesn't have a pen, but since there is a lot of TouchWiz shared code between Samsung devices. If you find an exposed public hook for the spen to use to take screenshots, you may be able to find one on Samsung devices that do not have the spen.

在一个侧面说明,如果你愿意支持的Tegra只器件。只有一些HTC设备和Xiomi设备甚至使用Tegra的,所以它没有这么大的市场份额。这似乎可以的:

On a side-note, if you're willing to support Tegra-only devices. Only some HTC devices and Xiomi devices even use Tegra, so it's not such a big marketshare. That would seem possible as well:

https://play.google.com/store/应用程序/详细信息?ID = net.tedstein.AndroSS

对于这一点,我建议你调查 HTC SDK 和Nvidia公司的 Tegra的开发包。对不起,我没有更多的时间来研究这些解决方案,为您的。请报告回到这里,告诉我们您的发现,无论是积极的还是消极的。

For that, I'd suggest you investigate the HTC SDK and the Nvidia Tegra Development Pack. I'm sorry I don't have more time to look into any of these solutions for you. Please report back here to tell us your findings, whether they are positive or negative.

这篇关于如何利用Android的屏幕没有扎根的手机本身的活动视图的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆