0
サービス内でgetWindow
を使用して表示できません。アプリケーション外の画面の表示方法
このビューは、アプリケーション外の画面で使用しました。
View v1 = getWindow().getDecorView().getRootView();
サービス内でスクリーンショットをキャプチャするにはどうすればよいですか?
またはアプリケーション外の画面でどのように表示を取得できますか?
サービス内でgetWindow
を使用して表示できません。アプリケーション外の画面の表示方法
このビューは、アプリケーション外の画面で使用しました。
View v1 = getWindow().getDecorView().getRootView();
サービス内でスクリーンショットをキャプチャするにはどうすればよいですか?
またはアプリケーション外の画面でどのように表示を取得できますか?
パンチライン:あなたは質問に非常に悪いです。
しかし、私は理解した質問に答えようとします。
スクリーンショットを取得するにはどうすればよいですか?
private void getScreenshot() {
try {
String imagePath = Environment.getExternalStorageDirectory().toString() + "/" + /*NAME*/ + ".jpg";
View view = getWindow().getDecorView().getRootView();
view.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
File imageFile = new File(imagePath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
あなたは今スクリーンショットで何をしたいのですか?
また、私はあなたが欲しい場合は、そのさらに明確にすることができ、と
View v1 = getWindow().getDecorView().getRootView();
をお願いしたいと思ったものを理解していませんでした。
これらをお読みください:[page1](http://stackoverflow.com/help/how-to-ask)[page2](http://stackoverflow.com/help/mcve)[page 3](http: /stackoverflow.com/help/on-topic) –