Is it possible to take screenshot in unrooted andr

2019-06-14 19:52发布

I am developing an application in which there is a button on click of that button i want the screenshot of android screen not that application screen my phone is unrooted. Is it possible to take screenshot of unrooted phone.?

1条回答
对你真心纯属浪费
2楼-- · 2019-06-14 20:12

Yes it is possible.

have a look at Android Screenshot Library.

Android Screenshot Library (ASL) enables to programmatically capture screenshots from Android devices without requirement of having root access privileges. Instead, ASL utilizes a native service running in the background, started via the Android Debug Bridge (ADB) once per device boot.

How to Implement?

Modifying the manifest XML

In order for Android service to be accessible, add the following declaration to your client application's XML manifest:

<service android:name="pl.polidea.asl.ScreenshotService">
    <intent-filter>
            <action android:name="pl.polidea.asl.ScreenshotService.BIND" />
            <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</service>

Binding service

To obtain the IScreenshotProvider interface one must bind to the ASL service (pl.polidea.asl.ScreenshotService) using Context.bindService - for example:

// (using class name)
Intent intent = new Intent();
intent.setClass (this, pl.polidea.asl.ScreenshotService.class);
bindService (intent, aslServiceConnection, Context.BIND_AUTO_CREATE);

References

查看更多
登录 后发表回答