Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to create a notification from the command line (terminal emulator or shell script)?

I would like to create a notification (icon in notification bar plus message in notification drawer) from a shell script that I'm running on my android device. I have CyanogenMod11, which comes with BusyBox v1.22.1 bionic.

I've discovered how to create a toast (http://forum.xda-developers.com/showthread.php?t=773232) but what I need is a notification. For difference between toast and notification, see this excellent thread: https://android.stackexchange.com/questions/52789/popups-dialogs-notifications-toasts-whats-the-difference

Can anyone point me in the right direction? I'm guessing it will involve the Android Activity Manager (am) but I've searched every nook and cranny of the internet and cannot find a way to create a notification from the command line on android.

like image 611
bdantas Avatar asked Oct 20 '22 10:10

bdantas


1 Answers

source: https://forum.xda-developers.com/showpost.php?p=69859668&postcount=18

date: 30th November 2016, 02:32 PM

Two years ago I was in need of a simple notification tool that could have been run by a command line in a script. So far the best I found was this thread and the tiny app made by corruptor64. That wasn't exactly what I was looking for so I finally decided to try to make the tool by myself. Starting from scratch (I am not an Android developer) in a few days of studying and developing I ended up with a working small app, that I named Notify4Scripts and I made it public only this past June, here on GitHub https://github.com/halnovemila/Notify4Scripts

Note that since the app is basically a service that has to be launched by the Android's shell "am" (activity manager) command, the Android system needs to be rooted first in order to be able to use such am command and have notify4scripts executed.

like image 138
halnovemila Avatar answered Oct 29 '22 19:10

halnovemila