Android: write failed: EPIPE (Broken pipe) Error on write file

前端 未结 2 1175
無奈伤痛
無奈伤痛 2020-12-09 16:38

I was trying to take screenshot of the Android screen programatically. I had done the following code:

private void getsnap(){
    try{
        Process sh = R         


        
相关标签:
2条回答
  • 2020-12-09 17:23

    The problem is that your app does not have system permissions to access the surface flinger (which uses screen buffer and hw decoder to render your video file). In order to have these permissions you have to build (and sign) your app as a system app and locate it at the system/priv-app folder. In addition to that you have to add the following permission to this system app:

    <manifest package="com.yourapp.demo"
        android:versionCode="1"
       coreApp="true"
        android:sharedUserId="android.uid.media"
        android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    

    note the coreApp="true" android:sharedUserId="android.uid.media" parts.

    and you will have to add <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> permission.

    please checkout this as well: Permission denial: Can't access the SurfaceFlinger

    0 讨论(0)
  • 2020-12-09 17:38

    EPIPE issue usually happens when you either try to execute command which needs root permissions (getRuntime().exec) in your case on the device without it or run several root commands simultaneously. If you work on the emulator and need to root it I think you you can try this while the emulator is running:

    adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system  
    adb push su /system/xbin/su  
    adb shell chmod 06755 /system  
    adb shell chmod 06755 /system/xbin/su
    

    Here http://abd-tech.blogspot.com/2011/05/test-root-apps-on-android-emulator.html more detail explanation.

    0 讨论(0)
提交回复
热议问题