An empty file is saved when programmed in Android

code snippet

void takeSnapShot() 
    {
        Process process = null;
        try
        {
        process = Runtime.getRuntime().exec("/system/bin/screencap -p /sdcard/snapshot/test_2.png" );

        try
        {
            process.waitFor();
        } catch (InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        } catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }




    }

I get an empty file, but if I use the same command through the adb shell, I get my screen.

Any help would be appreciated.

+5
source share
1 answer

Edit: my previous answer was wrong, any application can use the screen capture command.

This may be a resolution issue. Do you have permission to write to SDCard? Check out this post that covers your topic: How to run an Android system application without root permission?

0
source

All Articles