1

i'm developing an app and need to make Activity that take snapshot from current content of device screen. note: i dont want take picture from my activity content or some view, i want take a picture from all of device screen content. ( like home screen or every applications that are on foreground). i googled many times and search so much.

there is an example code:

View screen = (View)findViewById(R.id.screen);
screen.setDrawingCacheEnabled(true);
bmScreen = screen.getDrawingCache();
showBitmap(bmScreen); // function that show my bitmap image 

with this code can capture my activity's view, but i dont want capture onlye my activity. i want make a thread that capture device screen with all of its contents. can everybody help me please?

4

1 に答える 1

1

主にセキュリティ上の理由から、これを行うことはできません。これが可能であれば、一部の不正なアプリが、デバイスで実行しているすべてのスクリーンショットをサイレントにキャプチャして送信する可能性があります。

これがシステム以外のアプリで利用できない理由:

Androidでは、SDKアプリケーションが特定のことを実行し、他のことを明示的に禁止します。アプリは別のアプリのデータを読み取ることは想定されておらず、同様にアプリは別のアプリの画面をキャプチャできません。Googleは、サードパーティのアプリが他のアプリのスクリーンキャプチャを取得することは想定されていないと明確に述べています。スクリーンキャプチャAPIの欠如は、意図的な決定であり、省略ではありません。ICSはスクリーンショット機能を提供しますが、システムによって実装され、サードパーティのアプリから起動またはアクセスできないようにするためにハードウェアトリガーが必要です。

これを行う方法はいくつかありますが、rootが必要(デバイスに依存するグラフィックバッファを直接読み取るため)であるか、すべてのデバイス/バージョンで動作することが保証されているわけではありません。

于 2012-06-11T08:40:16.830 に答える