Hi all,
I have been developing an app to use on android devices that can immensely improve my business performance and I have been trying to add a button that once clicked takes a screenshot of the current screen and then saves it into either the internal storage or external SD.
I have been looking into the below only to get the following error but I cannot see why, I have been looking for ages, any help would be greatly appreciated…
Assets\Scripts\CaptureScreen.cs(10,17): error CS1002: ; expected
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public void takeScreenshot()
{
uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE";
{
Date now = new Date();
android.text.format.DateFormat.format("dd-MM-yyyy_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/storage/extSdCard/Job" + now + ".jpg";
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e)
{
// Several error may come out with file handling or DOM
e.printStackTrace();
}
}
}