Skip to content

Instantly share code, notes, and snippets.

@MeteorVE
Last active August 24, 2022 18:42
Show Gist options
  • Save MeteorVE/9ec3e4e9fd3c33bc64090012c04cfc92 to your computer and use it in GitHub Desktop.
Save MeteorVE/9ec3e4e9fd3c33bc64090012c04cfc92 to your computer and use it in GitHub Desktop.
Android Easy to Read Notification
  1. Although we can send webhook msg to discord channel, sometimes it doesn't show in notification (I don't know why). So I find a notification maker App : notification maker
  2. Install adb tool, we don't need fully toolkit so we can install minimal-version from -> here
  3. Set up "Global Variable" for Windows or your os.
  4. Use Notification Maker App to create a notification.
  5. Run python file.
  • Look like: Cellphone ScreenShot

Thanks to KAI's contribution.

import subprocess
import os
import io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
def get_notification_msg():
temp_path = "./sms.txt"
cmd = f'adb shell dumpsys notification --noredact > {temp_path}'
subprocess.getoutput(cmd)
notification_log = None
with open(temp_path, "r", encoding="utf-8") as f:
notification_log = f.read()
# os.remove(temp_path)
return notification_log
def get_sms():
notification_logs = get_notification_msg()
notification_logs = notification_logs[notification_logs.find("NotificationRecord"):].split("NotificationRecord")
ret = []
ana = False
for s in notification_logs:
if "pkg=com.wagner.valentin.notificationmaker2" in s:
bigText_index = s.find('android.bigText')
start = s.find('(', bigText_index)
end = s.find(')', start)
ret.append(s[start+1:end])
return ret
smss = get_sms()
print(smss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment