2014-02-13 28 views
0

我創建了一個在其他應用上運行的服務。我希望服務能夠在用戶看到整個屏幕時截取屏幕截圖,而不管正在運行什麼應用。我可以讓該服務運行手機的屏幕截圖功能並將其存儲在特定位置嗎?在Android中從服務中獲取屏幕截圖

+0

據我所知,這是無法完成的。您只能截取您應用中的內容。 –

回答

3

我可以讓服務運行手機的屏幕截圖功能並將其存儲在特定位置嗎?

否,除了可能在根植設備上,出於明顯的隱私和安全原因。

0

好,類似的問題一直非常受歡迎的計算器:

How to programmatically take a screenshot in Android?

How to take screenshot programmatically?

how to take screenshot programmatically and save it on gallery?

特別是,這個人是有用的:

// image naming and path to include sd card appending name you choose for file 
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + 
ACCUWX.IMAGE_APPEND; 

// create bitmap screen capture 
Bitmap bitmap; 
View v1 = mCurrentUrlMask.getRootView(); 
v1.setDrawingCacheEnabled(true); 
bitmap = Bitmap.createBitmap(v1.getDrawingCache()); 
v1.setDrawingCacheEnabled(false); 

OutputStream fout = null; 
imageFile = new File(mPath); 

try { 
    fout = new FileOutputStream(imageFile); 
    bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout); 
    fout.flush(); 
    fout.close(); 

} catch (FileNotFoundException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 

由Mualig,從上面的帖子之一。