2014-02-18 68 views
-1

我如何通過android.I屏幕捕獲的意思是我想編寫一個程序,使screen.any鏈接截圖感謝,謝謝大家以屏幕的screeshot通過Android手機

+0

您的應用程序或任何應用程序? –

+0

什麼?可以給我詳細信息 – sakir

+0

您想截取自己的應用或任何應用的截圖嗎? –

回答

1

我使用此代碼截圖我的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("[email protected]"); 
    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; 
} 
+0

我剛剛下載了一個程序whick採取任何app.how可能的屏幕截圖 – sakir

+0

安卓市場上的應用程序的名稱易於screeshot – sakir

+0

你是電話** ROOTED **? –

3

這不是儘可能輕鬆地按照你的意願去做。出於安全原因,沒有官方的API。

這裏是你的選擇:

  • 使用擷取畫面命令行工具:需要root權限,在所有手機
  • 獲取幀緩衝區沒有安裝:需要root
  • 使用android-screenshot-library:需要ADB連接爲開始