I succeeded to send the message in English, but with Hebrew it raises an error. I checked also with the default sms app on my android phone and it works fine with Hebrew. This is my code:
import subprocess
import time
def run_adb_command(command):
subprocess.run(command, shell=True, encoding='utf-8')
def open_whatsapp_with_message(code, number, message):
url = f'https://api.whatsapp.com/send?phone={code}{number}'
command = f'adb shell am start -a android.intent.action.VIEW -d "{url}"'
run_adb_command(command)
time.sleep(3)
input_command = f'adb shell input text "{message}"'
print(input_command)
run_adb_command(input_command)
time.sleep(1)
keyevent_command = 'adb shell input keyevent'
run_adb_command(f'{keyevent_command} 21')
run_adb_command(f'{keyevent_command} 21')
time.sleep(1)
run_adb_command(f'{keyevent_command} 21')
run_adb_command(f'{keyevent_command} 21')
run_adb_command(f'{keyevent_command} 66')
def process_numbers(numbers):
code = "+"
message = "בדיקה"
for number in numbers:
open_whatsapp_with_message(code, number, message)
time.sleep(5) # Add a delay between each iteration
# Example usage
number_list = ["12345678", "87654321"]
process_numbers(number_list)
the error:
java.lang.NullPointerException: Attempt to get length of null array
at com.android.commands.input.Input$InputText.sendText(Input.java:168)
at com.android.commands.input.Input$InputText.run(Input.java:140)
at com.android.commands.input.Input.onRun(Input.java:107)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:60)
at com.android.commands.input.Input.main(Input.java:71)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:409)
I cannot see any text in Hebrew that's written, its just jumping to the next contact on list.