I am attempting to take a screenshot of the emulator, but I am unable to save to photo.
@RunWith(AndroidJUnit4::class)
class ScreenshotTest : ScreenCaptureListener {
private var device: UiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@get:Rule
var mRuntimePermissionRule = grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@get:Rule
var activityRule = ActivityTestRule(MainActivity::class.java , true)
@Test
fun testScreenshot(){
var directory = File("C:\\Users\\me\\Desktop\\Screenshot_Pics", "pic.png")
device.takeScreenshot(directory)
}
This is effectively my code, and the manifest file also contains these lines:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I am unsure the main cause of this issue. I am guessing it has to do with the permissions because I think I have tried most other possible like setting my emulators graphics to use my computer's.