-1

我有一家小公司,我想制作一个相当简单的 python3 程序,该程序将在我的手机上使用 SL4A 在 Qpython3 上运行。它的目的是通过我的个人手机向我的客户发送带有优惠(我将其电话号码存储在列表中)的群组短信,因为我有无限的短信。

我设法创建了一个发送文本的程序(下面的相关片段),但问题是我现在在列表中收集了很多数字。发送文本时,会在我的消息中为每个客户创建一个新线程,因此每次发送群组短信时都会创建大约 550 个线程,最终我会手动删除它们,这对于下面的我的个人短信线程来说是相当烦人的.

我想请求的是帮助创建一个短代码片段,脚本发送的短信将在发送后立即删除,因此总体而言,在发送所有短信后,与这些相关的线程不会出现在我的消息应用程序中(默认三星 Galaxy s4 应用程序)。另外,有没有办法发送消息,以便只有在前一条消息被确认已发送(不在发送过程中)后才发送下一条消息,因为为了阻止我的手机冻结,我目前只使用 time.sleep?

import androidhelper, time
droid=androidhelper.Android()

#loads of irrelevant code here
#example values of variables numbers and message below
numbers=["0000000001","000000000002","000000000000003"]
message="This is a sample message."

for number in numbers:
    droid.smsSend(number,message)
    #The code below is here so that the texts don't fail to send as they did before I added this in. Hopefully, you could help me to replace it with something to wait for the previous sms to be confirmed as sent.
    time.sleep(3)

请帮我解决这个问题。我会很感激。提前感谢任何回复的人。

4

2 回答 2

1

尝试:

import sl4a, time
droid=sl4a.Android()

和国际格式的数字: ['+7989xxxxxxx', '+7961xxxxxxx'] 这在 qpython 3 中对我有用

于 2015-08-23T13:52:24.853 回答
1

我使用这段代码没有问题:

进口

import androidhelper, time
import sl4a

设置 sl4a

droid = sl4a.Android()

在这里,您输入一条提示消息,该消息将创建一个空输入来键入您的消息

message = droid.dialogGetInput('This text will prompt for the message you want to send').result

将您输入的内容转换为 StringVariable

message = str(message)


numbers = ('phone number one', 'phone number two', 'phone number ETC')
for number in numbers:
     droid.smsSend(number, message)
     time.sleep(3)

if __name__ == '__main__':
     droid = sl4a.Android()
于 2015-12-31T06:18:49.723 回答