The easy way to take screenshots of your application programmatically.
Include the below dependency in your build.gradle
project.
buildscript {
repositories {
jcenter()
maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local"
metadataSources {
artifact()
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.newtronlabs.android:plugin:4.0.5'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local"
metadataSources {
artifact()
}
}
}
}
subprojects {
apply plugin: 'com.newtronlabs.android'
}
In the build.gradle
for your app include:
dependencies {
compileOnly 'com.newtronlabs.easyscreenshot:easyscreenshot:2.0.0'
}
Sample on how to use it.
public class MainActivity extends AppCompatActivity implements ICaptureListener
{
private static final String TAG = "EasyScreenshot";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ScreenshotAdapter.getInstance().capture(this, this);
}
@Override
public void onResult(@Result int result, Bitmap bitmap)
{
if(result == Result.FAILED)
{
Log.d(TAG, "Failed");
return;
}
Log.d(TAG, "Succeeded");
boolean res = ScreenshotAdapter.getInstance().saveToFolder(bitmap, "Screenshots", "MyScreenshot");
}
}
Please support the continued development of these libraries. We host and develop these libraries for free. Any support is deeply appriciated. Thank you!
BTC Address: 39JmAfnNhaEPKz5wjQjQQj4jcv9BM11NQb
https://gist.github.com/NewtronLabs/216f45db2339e0bc638e7c14a6af9cc8