在PC上执行adb shell,但是python由于环境变量问题不可以直接在adb的shell中调用。
/etc/profile
mount -t tmpfs tmpfs /data/tmp chmod 1777 /data/tmp export EXTERNAL_STORAGE=/mnt/sdcard PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload export PYTHONPATH export TEMP=/data/tmp export PYTHON_EGG_CACHE=$TEMP export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib
然后在/sbin下建个软连接到/data/data/com.googlecode.pythonforandroid/files/python/bin/python即可
ln -s /data/data/com.googlecode.pythonforandroid/files/python/bin/python /sbin/python
最后,手机上开启Script Monitor Service
SL4A->Menu->View->Interpreters, Menu->Starft Server->Private
后来找到官网有详细教程,如下。
https://code.google.com/p/android-scripting/wiki/RemoteControl