【问题标题】:sl4a python make a Toast for android phonesl4a python 为安卓手机制作吐司
【发布时间】:2013-10-06 21:09:00
【问题描述】:

我使用SL4A在python中只写了这3行:

    import android
    droid = android.Android()
    droid.makeToast(u"ascc4r")

当此代码运行时,我收到以下错误:

pydev debugger: starting
Traceback (most recent call last):
  File "C:\Users\Tibi\Desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins        \org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1446, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\Users\Tibi\Desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins    org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1092, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "C:\Users\Tibi\workspace\26\src\26module.py", line 7, in <module>
    droid = android.Android()
  File "C:\Python26\lib\android.py", line 34, in __init__
   self.conn = socket.create_connection(addr)
  File "C:\Python26\lib\socket.py", line 547, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed

环境设置: - Python 2.6.6 - 设置 ap_port=9999 - adb forward tcp:9999 tcp:xxxx (xxxx 我在手机上启动服务器的地方) 我的 android.py 位于 Python/Lib 文件夹中。

更新: 我在 CMD 中尝试了这 3 条指令,它的工作,制作吐司。所以我认为问题出在 ADT 包或 Eclipse Python 插件上。

这个 Errno 11001 是什么?

【问题讨论】:

  • 尝试使用 sl4a 模块(导入 sl4a)。

标签: android python python-2.7 sl4a


【解决方案1】:

这个 Errno 11001 是什么?

我不知道那个错误,但我建议使用正确的语法,即

 import android
 droid = android.Android()
 droid.makeToast('my text to print should be inside the quotes')

另见API Overview

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多