Android 将屏幕内容转换为文档格式,然后让用户在手机上下载该文档

Android 将屏幕内容转换为文档格式,然后让用户在手机上下载该文档,android,download,doc,Android,Download,Doc,我正在开发一个应用程序,在该应用程序中,用户只允许填写表单一次,下次用户查看表单时,表单应为doc类型,并且可以在其手机上下载 我不知道这个链接是可能的还是不可能的。如果可能的话,那么怎么做。请建议我一个选项或提供一些有用的代码链接 我搜索了一下,但没有找到任何有用的东西 我使用了以下问题的代码 但我落后的地方是我没有办法将整个屏幕转换成doc/pdf。在StackOverflow中也有类似的问题。这将有助于: 这也是: 查看此代码,将屏幕另存为图像 private void saveI

我正在开发一个应用程序,在该应用程序中,用户只允许填写表单一次,下次用户查看表单时,表单应为doc类型,并且可以在其手机上下载

我不知道这个链接是可能的还是不可能的。如果可能的话,那么怎么做。请建议我一个选项或提供一些有用的代码链接

我搜索了一下,但没有找到任何有用的东西

我使用了以下问题的代码


但我落后的地方是我没有办法将整个屏幕转换成doc/pdf。

在StackOverflow中也有类似的问题。这将有助于:

这也是:

查看此代码,将屏幕另存为图像

private void saveImages() {
    View v = findViewById(R.id.view_images);
    v.setDrawingCacheEnabled(true);

    // this is the important code :)
    // Without it the view will have a dimension of 0,0 and the bitmap will
    // be null
    v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
            MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());

    v.buildDrawingCache(true);
    Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false); // clear drawing cache

    SimpleDateFormat dateFormat = new SimpleDateFormat(
            "yyyyMMddHHmmss");
    Date date = new Date();
    String name ="data"+"-"+dateFormat.format(date) + ".png";
    // String imageName = "TEST" + (String) name;

    File folder = new File(Environment.getExternalStorageDirectory()
            + "/.TEST");
    // boolean success = false;
    if (!folder.exists()) {
        folder.mkdir();
    }

    File file = new File(folder + "/TEST" + name);
    try {
        file.createNewFile();
        FileOutputStream ostream = new FileOutputStream(file);
        b.compress(CompressFormat.PNG, 100, ostream);
        ostream.close();
        Log.d("Done", "Yes");
        Toast.makeText(getApplicationContext(),
                "Images" + name + "save in Sd card", Toast.LENGTH_SHORT)
                .show();
    } catch (Exception e) {
        e.printStackTrace();
        Log.d("Done", "No");
        Toast.makeText(getApplicationContext(),
                "Images in Sd card", Toast.LENGTH_SHORT).show();
    }
    finish();

}