[REQ] very small app to display "toast" msg

Dexter_nlb

Senior Member
Feb 12, 2009
5,459
4,549
0
Copenhagen
I am in need of a very small app (just a few lines of code) to display a "toast" message in the active window.

I have the milestone, and made some mods on it, and using the hw keyboard i made shortcuts to execute functions and i would like to display a status from the scripts, and so far it only works with Beanshell(Android Scripting Environment), but the window popup is simply to annoying. so if somebody can make the toast command in a java app, and add the, i think, intent call function so i can execute this using "am" from shell script.

Yes, i know, i could probably do it myself, but i am no good at the "I-went-to-the boat->on my cycle->using my legs" object oriented programming thingy..

If anybody can help me out, any help is appreciated...
 

corruptor64

Member
Dec 11, 2007
17
17
0
I was interested in looking into this to help my growth of android, so gave it a shot.

This is an app that starts, displays the input message, then exits.

run it through command line using the following:

am start -a android.intent.action.MAIN -e message mytoastmessage -n com.rja.utility/.ShowToast

whatever is passed in for the 'message' is displayed in a long toast.

if nothing is passed a toast saying such is displayed.

Let me know if this works for you.
 

Attachments

Last edited:

ngagephone

Senior Member
Jul 24, 2006
746
156
0
35
Doncaster (Town)
I was interested in looking into this to help my growth of android, so gave it a shot.

This is an app that starts, displays the input message, then exits.

run it through command line using the following:

am start -a android.intent.action.MAIN -e message mytoastmessage -n com.rja.utility/.ShowToast

whatever is passed in for the 'message' is displayed in a long toast.

if nothing is passed a toast saying such is displayed.

Let me know if this works for you.

Hmm cant get it to work can you write a example script and upload plz thanks.
 

corruptor64

Member
Dec 11, 2007
17
17
0
Ok it works now is there any chance you can reupload your app but make the icon from the app drawer gone you can do this by removing <category android:name="android.intent.category.LAUNCHER" /> from the manifest file thanks in advance.
Good call on removing the icon from the drawer. It really doesn't belong there for this type of application.
 
Last edited:

corruptor64

Member
Dec 11, 2007
17
17
0
I edited the original reply and added a signed apk for the no drawer icon version.

The original version will expire in a year and will not be able to be installed after that since it was signed using debug certs which are valid for a year after the apk was created.

Download the latest one and use that. Glad i could help.
 
  • Like
Reactions: acuicultor

foxdog66

Senior Member
Jul 28, 2010
471
53
0
cool, can you guys make one to play a sound? or is their a script or line of code that will play a sound? I made a few scripts to download/install a boot animation but i cant figure out how to notify once its done, thats what im going for. as of right now it just reboots the phone when its done.
 

Dexter_nlb

Senior Member
Feb 12, 2009
5,459
4,549
0
Copenhagen
I was interested in looking into this to help my growth of android, so gave it a shot.

This is an app that starts, displays the input message, then exits.
thanks alot! it already sounds like it works for others.. this is a very nice idea for giving status backs in customs, so its worth alot for modders somehow, when the java is not a knowledge you have :)

ill test it tomorrow and see how it works out.
 

Dexter_nlb

Senior Member
Feb 12, 2009
5,459
4,549
0
Copenhagen
I edited the original reply and added a signed apk for the no drawer icon version.

The original version will expire in a year and will not be able to be installed after that since it was signed using debug certs which are valid for a year after the apk was created.
resigning when making new mods is less a problem, than coding it :)
im sure it'll work out in the end...
 

ngagephone

Senior Member
Jul 24, 2006
746
156
0
35
Doncaster (Town)
Damn i think i spoke to soon it works fine via the adb shell it shows the msg i made on the phone but if i try to run it in terminal emulator on the phone it does not work. Any ideas? if any one has it working via terminal emulator do you mind uploading a sample script?
 

corruptor64

Member
Dec 11, 2007
17
17
0
Damn i think i spoke to soon it works fine via the adb shell it shows the msg i made on the phone but if i try to run it in terminal emulator on the phone it does not work. Any ideas? if any one has it working via terminal emulator do you mind uploading a sample script?
It works through adb shell for me and using Terminal Emulator app on my phone. I copy and pasted the following in terminal emulator on my phone and it showed a toast as expected.

am start -a android.intent.action.MAIN -e message 'this is the displayed text in a toast' -n com.rja.utility/.ShowToast

I don't do scripting so can't help there, sorry. Hopefully someone else can provide you the script you need. From my perspective i think everything is good. Let me know if you find out otherwise.

Good Luck!
 
Last edited:

ngagephone

Senior Member
Jul 24, 2006
746
156
0
35
Doncaster (Town)
Hmm it does work the problem i had is i was making the scripts in windows using notepad++ and i have noticed if i open the script on android i have blocks at the ends of each line. I have had this problem in linux when doing scripts via windows. Any way its not a problem with your app so thanks.
 

Dexter_nlb

Senior Member
Feb 12, 2009
5,459
4,549
0
Copenhagen
Hmm it does work the problem i had is i was making the scripts in windows using notepad++ and i have noticed if i open the script on android i have blocks at the ends of each line. I have had this problem in linux when doing scripts via windows. Any way its not a problem with your app so thanks.
UltraEdit rulez!
 

corruptor64

Member
Dec 11, 2007
17
17
0
cool, can you guys make one to play a sound? or is their a script or line of code that will play a sound? I made a few scripts to download/install a boot animation but i cant figure out how to notify once its done, thats what im going for. as of right now it just reboots the phone when its done.
Per this request, I made an app that plays a specified sound stream for the duration requested. It does not force a specific sound, but plays whatever sound is set for the type at the time.

/*
* Example run command:
* am start -a android.intent.action.MAIN -e raisevolume 'true' -e soundduration '8000' -e soundtype 1 -n com.rja.utilities/.PlaySound
*
* Program Options and valid values:
* Not passing in a flag is the same as passing false.
* raisevolume - boolean that forces the sound to be played.
* - sets sound mode to normal and raises volume to max - after sound is played, resets mode and volume to previous values
* soundtype - number to indicate type of sound to play
* - Valid Values:
* - 0 - ringtone
* - 1 - notification
* - 2 - alarm
* soundduration 8000 -- if nothing is passed default is 4000. This is the duration the sound is played.
*/

Please let me know if you have any questions or problems with it.
 

Attachments

halnovemila

Senior Member
Sep 18, 2014
72
67
0
www.controsensi.it
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.
 
Last edited:
  • Like
Reactions: igcek and Deic

mirfatif

Senior Member
Oct 18, 2016
635
347
63
Two years ago I was in need of a simple notification tool...
  • Could you please write an intent to open a directory given as a variable when I tap notification. I want to use it with clamav daemon running on my phone so that I can open the directory containing infected file when I get the notification. Please note that directory can be out of $EXTERNAL_STORAGE e.g. /data/data/ which is only accessible with root privileges.
  • Can the notification be multi lined or expandable with "b_noicon 0" so that complete path and virus name is visible before opening the directory?
Thanks for this great tool.
 

halnovemila

Senior Member
Sep 18, 2014
72
67
0
www.controsensi.it
  • Could you please write an intent to open a directory given as a variable when I tap notification. I want to use it with clamav daemon running on my phone so that I can open the directory containing infected file when I get the notification. Please note that directory can be out of $EXTERNAL_STORAGE e.g. /data/data/ which is only accessible with root privileges.
  • Can the notification be multi lined or expandable with "b_noicon 0" so that complete path and virus name is visible before opening the directory?
Thanks for this great tool.
Hi,
the intent depends on the app you are willing to use to "open" the target folder.
If you are willing to use a terminal emulator app you can look at the many example I've wrote on the wiki available at the GitHub page of my tiny project (here's the direct link to the wiki https://github.com/halnovemila/Notify4Scripts/wiki ).
In such examples I illustrate how to call the terminal emulator app and have commands passed to it for execution.
If you'd like to use other apps, like a file explorer app, then you need to know the proper intent for that app.
The "easy" way is to make a home screen shortcut of the app opening a folder, then locate the Launcher app database, open it and read the intent used for the shortcut (that's how I found out all the intent used in the examples).

When the notification layout is set to "Custom View" (which always is when b_noicon is set to 1) multi lines text content is possible (also with use of \n new line escape code in the text) but it's not "expandable". You can adjust the content text size and remove the title line (with str_title "") to gain more room and be able to fit longer text on the notification box.

Hope this helps
 
Last edited: