参考文档:http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App

假如我要执行的二进制文件名为capturescr,我的android程序包名为com.zklc.capture

一、使用assets 目录:

 1.把二进制文件capturescr放到assets目录中

 2.使用InputStream is = getAssets().open("capturescr"); 

 3.把二进制文件capturescr拷贝到/data/data/com.zklc.capture目录下

 4.执行 "/system/bin/chmod 744 /data/data/com.zklc.capture/capturescr"   属性改成可读可写可执行

 5.执行capturescr就可以了,使用下面命令行

















//java中执行命令  public void execCommand(String command) throws IOException {
  
        Runtime runtime = Runtime.getRuntime();
        Process proc = runtime.exec(command);         try {
            if (proc.waitFor() != 0) {
                System.err.println("exit value = " + proc.exitValue());
            }
        catch (InterruptedException e) {
            System.err.println(e);
        }
    }


二、从网络下载capturescr

   下载capturescr文件,按照第一种方法的3、4、5步即可。

三、通过adb(需要Root)

  

1 2 3 4 5 6 7 8 9 10 % adb shell su # mkdir /data/tmp # chmod 777 /data/tmp # exit exit % adb push yourapp  /data/tmp % adb shell chmod  744  /data/tmp/yourapp /data/tmp/yourapp

注意:可执行文件不能放在sdcard目录下


更多相关文章

  1. 2011.08.18(2)——— android 自定义组合组件 onFinishInflate onS
  2. Java(Android)线程池
  3. 新手学Android
  4. android wearable 研究
  5. Android开发菜鸟到高手必备的十本畅销书籍
  6. (4.1.10) ImageView图片自适应
  7. android 多线程 AsyncTask handler
  8. 4.11笔记 android database打开方式,ios反射
  9. Android(安卓)- adb : logcat / shell / app_process & android.

随机推荐

  1. 在Android(安卓)Studio自己的项目中使用G
  2. 【Android开源项目解析】仿支付宝付款成
  3. 摄像头Camera视频源数据采集解析
  4. Android(安卓)获取本机号码(收集)
  5. Android5.0 下拉通知栏快捷开关的添加(必
  6. android 上面一个listview下面一个button
  7. Android关于Activity知识点总结(一)生命周
  8. Android(安卓)开发自己的网络收音机1——
  9. Android中提供的免费文字转语音功能TextT
  10. 基于frida的几种安卓脱壳工具