2014-02-18 70 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连接为开始