0

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.

5
  • See: Typing on an Android Device straight from computer? and adb shell input unicode character Commented Jun 14, 2023 at 13:54
  • The chance for unicode text survive the "long travel" from python to the shell (what ever is actually used) into adb client to adb server and then to adb-daemon o the Android phone and there in the shell to the command and finally to the app is next to zero. I would try to cut down the distance by e.g. using pure-python-adb. That would reduce the pipe length and directly send the data from python to adb server on your PC. Commented Jun 14, 2023 at 14:45
  • @MorrisonChang I tried both methods and I still can't see the message. Commented Jun 14, 2023 at 15:38
  • @Robert I tried this also and it didn't work. if someone could try it and send here the working code ill be thankful Commented Jun 14, 2023 at 15:39
  • @eitan You should update your post with details about which methods were tried and what errors did you get. Commented Jun 14, 2023 at 16:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.