'Take screenshot based on button click on the any app on android
I am trying to writing a script which will open a specific app on my android mobile and navigate through some search in the app and take screenshots.
Any ideas? The challenge I am facing is not taking screenshot but to navigate to the specific app and navigate through few tabs in it to take screeshot.
I tried using mitmproxy to look for network traffic but for some reason it is blocked on my laptop.
Solution 1:[1]
First create a directory through programmatically and then specify the path where you want to save your screenshot.
Either you can save path in Any location in you mobile and when you need that image call image path and change image path to Bitmap and apply to imageView
private void getScreenshot(){
View v = view.getRootView();
v.setDrawingCacheEnabled(true);
Bitmap bm = v.getDrawingCache();
String str = Environment.getExternalStorageDirectory().toString();
File yourPath = new File(str, getString(R.string.free_tiket)+".jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(yourPath);
bm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
MediaStore.Images.Media.insertImage( getContentResolver(), bm, "Screen", "screen");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ashok |
