[TUT] Extend your HelloWorld App Step by Step with a Toast Message - Android Software/Hacking General [Developers Only]

Hi guys, this Tutorial is mainly intended for looking into some other concepts like GUI of Android development. The concept of "Toast" would be actually covered.
First you have to do this (Create a HelloWorld app) : [TUT] Making a HelloWorld App Step by Step w/pictures. - Tutorial created by rezo609
After you've created your first HelloWorld app, its time for some additional tasks!
(NOTE:- Make sure you've set your AVD already)
I know some of you guys are wondering what a Toast is, well here's the answer: Click Me!
Starting development :
Step 1: The first thing we are going to accomplish is changing the strings.xml (Path:- AppName > res > values > strings.xml) file to add another node under app_name. We will do this by copying the node above it and pasting the copied material directly under the last </string> element. Then we will change the name of the string to press and in between we will write Press Me!. Next we will alter the hello node and change the text to say Enter Your Name Here: instead of Hello Android, Hello World!.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click to expand...
Click to collapse
Step 2: Next step, is to design the GUI (Graphical User Interface). To do this navigate to main.xml (Path:- AppName > res > layout > main.xml) and we are going to go over what everything does up to this point. Set your main.xml file as shown in the below picture.
Make sure you've set the Orientation as vertical, otherwise ie, if its horizontal maybe the GUI controls won't be shown when the app is run.(in an HVGA Emulator, or maybe its me) Anyways you are free to toggle between vertical/horizontal and see what happens.
Click to expand...
Click to collapse
Step 3: Now this is a tricky step, and it includes Java code modifications. I suggest you to google to know exactly what all these codes means be it functions, classes, methods, objects or imports. You can refer the Wiki or the Oracle docs if you want to learn more about Java. Anyways for keeping this Tutorial simple, just modify the Java file (Path:- AppName > src > com.example.helloworld > HelloWorldActivity.java) as shown in the below picture.
I'll also give it as CODE, but don't just copy-paste. If you run into massive errors or problems only, do that. Its better to type the codes by yourself and see what all AutoFill options/suggestions are given by Eclipse. Anyways try to correct the errors by yourself, it maybe only a spelling-mistake, but you have to identify it where.
Code:
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.view.View.OnClickListener;
import android.content.Context;
import android.view.View;
public class HelloWorldActivity extends Activity {
EditText helloName;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Capture our button from layout
Button button = (Button)findViewById(R.id.go);
// Register the onClickListener with the implementation above
button.setOnClickListener(maddListener);
}
// Create an anonymous implementation of OnClickListener
private OnClickListener maddListener = new OnClickListener() {
public void onClick(View v) {
long id = 0;
// Do something when the button is clicked
try {
helloName = (EditText)findViewById(R.id.helloName);
Context context = getApplicationContext();
CharSequence text = "Hello " + helloName.getText() +"!";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
catch(Exception e) {
Context context = getApplicationContext();
CharSequence text = e.toString() + "ID = " + id;
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
};
}
Click to expand...
Click to collapse
Step 4: After doing all these above mentioned tasks, its time for the output. Be sure to click "Save All" (Ctrl+Shift+S) button in the Eclipse. Also make sure your Project is free from errors, otherwise it would not run. You can also clean your Project (Some errors maybe automatically fixed) by navigating to Project > Clean...
Right Click your Project > Run As > 1 Android Application
Your Emulator would start, and you'll see in the Eclipse as apk installing, running etc..
If your Project is a Success, you'll get the output as shown in the below picture:
Click to expand...
Click to collapse
And that's it
I hope you enjoyed this tutorial. Its made as simple as possible and omitted some theories from the Original source. You can get to it, and see the xml parts explained.

After you have succeeded in this app, head over to next Tutorial : Create your First Widget Step by Step

Thanks for this.

This is great!!
Sent from my HTC Wildfire S using xda premium

Welcome guys, hope you guys tried/will try and get successful.

Tutorial now featured at XDA-Portal : Here
Thanks to the Author.

So I decided to look at this. I've got everything as you have above but I have errors.
Current errors are in the following lines:
Code:
Button button = (Button)findViewById(R.[COLOR="Red"]id[/COLOR].go);
Code:
helloName = (EditText)findViewById(R.[COLOR="red"]id[/COLOR].helloName);
The error states: id cannot be resolved or is not a field
If I follow the listed fixes it places lines in the R.java. However, I then get errors on go and helloName for which there are no listed fixes.
Still looking to see if I can find it myself but wanted to tell you about this to see if it was just me (probably) or a missing section in the info above.
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.

blazingwolf said:
So I decided to look at this. I've got everything as you have above but I have errors.
Current errors are in the following lines:
Code:
Button button = (Button)findViewById(R.[COLOR="Red"]id[/COLOR].go);
Code:
helloName = (EditText)findViewById(R.[COLOR="red"]id[/COLOR].helloName);
The error states: id cannot be resolved or is not a field
If I follow the listed fixes it places lines in the R.java. However, I then get errors on go and helloName for which there are no listed fixes.
Still looking to see if I can find it myself but wanted to tell you about this to see if it was just me (probably) or a missing section in the info above.
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.
Click to expand...
Click to collapse
please check the imports ...
if you find line import android.R; ... remove it and then clean build....

blazingwolf said:
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.
Click to expand...
Click to collapse
There you are
Actually we should edit all the XML files first like android:id="@+id/go" and it will show error in XML file for sure (Because id can't be found anywhere) but finally when you code the java file, and when the id is referenced, all errors will be gone
Anyways the R.java file can't be modified manually. It will revert back to original state if you do so, that is even if you apply the suggested fixes by Eclipse.

pmapma1 said:
please check the imports ...
if you find line import android.R; ... remove it and then clean build....
Click to expand...
Click to collapse
Actually unnecessary imports will not cause the application to malfunction. It will only use more resources based on program. Eclipse will give a warning to remove unused imports, as its not used anywhere.

Hi there,
I've been wondering this so I thought I'd ask here since it seems nice and n00b friendly ;-)
I was wondering if you could tell me if there's any direct benefit to creating an OnClickListener in Java instead of using the android:OnClick="" attribute for the layout and having it go to a specified method.
Thanks,
Tom

TommiTMX said:
Hi there,
I've been wondering this so I thought I'd ask here since it seems nice and n00b friendly ;-)
I was wondering if you could tell me if there's any direct benefit to creating an OnClickListener in Java instead of using the android:OnClick="" attribute for the layout and having it go to a specified method.
Thanks,
Tom
Click to expand...
Click to collapse
Benefit?! ... Hmm !!
It all depends upon the logic of the programmer that he/she is comfortable with. Actually there will be many methods or many ways we can create for the same process. But as this is just a Tutorial/Illustration application, we don't know exactly what its effects. Maybe in real time application there maybe some beneficiaries. Just we need to sort it out to know.

can you make a tutorial how to make a background process? Or service of somekind.
E.g. process that shows blue led while BT is on
thanks in advance!

Shmarkus said:
can you make a tutorial how to make a background process? Or service of somekind.
E.g. process that shows blue led while BT is on
thanks in advance!
Click to expand...
Click to collapse
I'll definitely try, but can't guarantee when because I'm also a learning candidate in Android app development. So making Tutorials, that I've already learned and tried. Once I've learned about it, I'll of course include the Tutorial for it.

why we need try/catch for one-way trigger? ... what in toast can throw exception?

Flowyk said:
why we need try/catch for one-way trigger? ... what in toast can throw exception?
Click to expand...
Click to collapse
Well, I just checked myself by removing the try-catch block, and yes you are right as no exceptions are actually caught. Anyways the code is not actually written by me, and if you checked the original source you'd have known that.
And Thanks for the point mate. Maybe I'll review the code from next time onwards.

np ... im just learning

Error?
FIXXED

Related

[UTIL] ADB Suite

Hi, I am developing a little utility for easy work with ADB. Simple GUI alow many functions and others are incoming in every next relase.
Now is supported: Install single/multi APK, Upload files, Send commands, Restart normal/bootloader/recovery, Wipe system/data/all, Connect Mass Storage for reading and writing on PC and phone simultaneosly, Remount /system as write/read, Taking screenshots and Dialing numbers.
Many functions are accesible from tray icon
There is one little problem, util is developed in my language (CZE) > if interested, i can make multi language UI. Hmmm?
/Edit: Added multi language support in 0.8 ver
Known Bugs: no complete english translation, toolstrip bar is not fully working, file send to the sdcard not working
Code:
26.8.2009 - Changelog ver. 0.8
=> add support for mount /sdcard accesible from pc and phone in one time
=> edited About Box
=> Status Bar with tooltips
=> multi language support - english and czech
20.8.2009 - Changelog ver. 0.7:
=> screenshots from device (Detox DLL, thx)
18.8.09 - Changelog ver. 0.6:
=> remount /system as writeable
=> run at start up with windows
=> install mutli APK (all APK from directory "multiapp" on the sdcard)
=> edited AboutBox
17.8.09 - Changelog ver. 0.5:
=> dialing phone numbers
=> icons in menu
16.8.09 - Changelog ver. 0.4:
=> task bar icons with most useful functions
16.8.09 - Changelog ver. 0.3:
=> wipe support (system, data, all)
15.8.09 - Changelog ver. 0.2:
=> restart support (normal, bootloader, recovery)
15.8.09 - Changelog ver. 0.1:
=> install APK
=> send command directly to the device
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Just release it and the source
Making an English version would be a necessity, further translations can be done if anyone cares to translate it.
What programming language is it written in? I've started dusting off a similar project I'd been working on since ComplexMind is on hiatus with his "My Android Manager". I think if we can build a consolidated pc interface it would help out the community a lot. Open the source and I'm sure you'll have people beating a path to your door to help out.
VB.NET, i am plannig release source bot not yet... Wow, i never hear about My Android Manager but i checked now and I can stop develop this utility
kissman21 said:
VB.NET, i am plannig release source bot not yet... Wow, i never hear about My Android Manager but i checked now and I can stop develop this utility
Click to expand...
Click to collapse
My Android Manager sucks, it's slow and buggy.
kissman21 said:
VB.NET, i am plannig release source bot not yet... Wow, i never hear about My Android Manager but i checked now and I can stop develop this utility
Click to expand...
Click to collapse
I thought it looked like VB. You can definitely add me to the list of people interested in helping develop this further. My Android Manager hasn't moved for about a month. At least around here, that's quite a while. I've not worked much on localization before but dynamically labeling based on an indexed data file shouldn't be too hard. Do you currently use any sort of db storage or is strictly a command line wrapper at this point?
maxisma said:
My Android Manager sucks, it's slow and buggy.
Click to expand...
Click to collapse
I wouldn't say it sucks, but it is incomplete. Since the source is closed on it though we're at the whim of ComplexMind to fix things.
looking great! nice idea
but MAM have a "little thinks" about which i am thinkink "i must have in own app" such as phone detection and cmd output to gui.
Now I am using strictly defined commads and link library with functions for convert rgb565 to others usable formats. In future, i want make simple db with commands for easy updates and edits... And MUI is easy to implement, but need more time (work, work, work in IT is hard :-D )
kissman21 said:
VB.NET, i am plannig release source bot not yet... Wow, i never hear about My Android Manager but i checked now and I can stop develop this utility
Click to expand...
Click to collapse
so he posted this util and now is saying he is going to stop putting in the time?
just ironically My Android Manager have nice idea
kissman21 said:
but you have a "little thinks" about which i am thinkink "i must have in own app" such as phone detection and cmd output to gui.
Now I am using strictly defined commads and link library with functions for convert rgb565 to others usable formats. In future, i want make simple db with commands for easy updates and edits... And MUI is easy to implement, but need more time (work, work, work in IT is hard :-D )
Click to expand...
Click to collapse
Your time frames are your own, but around here people loose interest fast if things stop happening. My first thought with a back end db is that each control could be indexed and then captioned during a splash screen process for simple localization. Maybe crude, I'm not a professional programmer, but I think it would work. A quick Google search popped up a sample for capturing command line output. It would need a little work to adapt but I can see where it's going.
Code:
Dim CMD As New Process
Dim SW As System.IO.StreamWriter
Dim SR As System.IO.StreamReader
CMD.StartInfo.FileName = "cmd"
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.RedirectStandardInput = True
CMD.StartInfo.RedirectStandardOutput = True
CMD.StartInfo.CreateNoWindow = True
CMD.Start()
SW = CMD.StandardInput
SR = CMD.StandardOutput
SW.WriteLine("ping www.google.com")
CMD.Dispose()
SW.Dispose()
Do Until SR.EndOfStream = True
TextBox1.Text &= SR.ReadLine
TextBox1.Text &= Environment.NewLine
Loop
SR.Dispose()
i tried write a hundreds lines of code for creating nice shell output... even this but not works good
kissman21 said:
i tried write a hundreds lines of code for creating nice shell output... even this but not works good
Click to expand...
Click to collapse
I'll see if I can find some time to package this up as a class module and test it out. I'm watching the baby today so time is not my own. I think parsing the output would definitely be the tricky part. Then of course making that output useful.
2ben... your code have 2 big minus 1) when start command, application totaly freeze and waiting to command end 2) text output is writed after command ended better is System.Diagnostics.Process.Start
i'm fairly proficient in .net. looking forward to helping out. open up the source. better move on it quick though, these guys move fast.
kissman21 said:
2ben... your code have 2 big minus 1) when start command, application totaly freeze and waiting to command end 2) text output is writed after command ended better is System.Diagnostics.Process.Start
Click to expand...
Click to collapse
I think the "EndOfStream" property is not capturing correctly for some reason. It kept freezing for me when I first tried it. I've just about got it wrapped up in a module so the output is continually cached until the class is released. I'll try to post it soon, once it's working on my end that is.
i like this a lot. Looking good and willing to test. Can we have an English version though?
benmyers2941 said:
I think the "EndOfStream" property is not capturing correctly for some reason. It kept freezing for me when I first tried it. I've just about got it wrapped up in a module so the output is continually cached until the class is released. I'll try to post it soon, once it's working on my end that is.
Click to expand...
Click to collapse
I've successfully isolated the problem to the read stream not having the expected endofstream characters. I've not resolved a workaround though... yet.

Fullsize Home Screen Icon for Websites or Web Applications

Hi y'all.
Full Icons for the desktop are much better and should be used when available as opposed to the "lapel" style that android does natively.
Problem:
Today I got a google wave invite and brought up the mobile version. Then I added an icon to my desktop for easy access. Here is what it looked like (the bookmark text was edited)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As you can tell, it looks like a regular bookmark link but has the little google wave lapel. A bunch of sites do this.
However, when the same bookmark is make on the iphone it looks like this (bottom row, next to the poop icon) (not my phone had buddy ss it for me)
Here is the apple documentation for retrieving this icon:
How do I create a Home screen icon for my website or web application?
Safari on iPhone OS allows users to save a bookmark to your website or web application on the Home screen, alongside icons for native applications. For this bookmark, you can specify a single icon for your entire site or application by placing a 57 x 57 pixel .png image named apple-touch-icon.png in the root directory of your website. Or, to provide a specific icon for a section or page, use a link tag that defines the relationship as apple-touch-icon and includes a link to the icon image, as shown in Listing 3.
Listing 3: Specifying a per-page Home screen icon
<link rel="apple-touch-icon" href="/my_custom_icon.png"/>
Guidelines for creating Home screen icons are available in the "Create an Icon for Your Web Application or Webpage" section of the iPhone Human Interface Guidelines for Web Applications], and detailed information about linking your icon to your web content can be found in the "Specifying a Webpage Icon for Web Clip" section of the Safari Web Content Guide for iPhone OS.
Click to expand...
Click to collapse
http://www.devworld.apple.com/safari/library/codinghowtos/Mobile/UserExperience/index.html#GENERAL-CREATE_A_HOME_SCREEN_ICON_FOR_MY_WEBSITE_OR_WEB_APPLICATION
some more implementation details on the sites side
An article about today about the mobile google wave site and this logo
I am not a coder but am a product manager for software dev, so i can't code this up myself effectively.
Initial Proposal / Method
My guess would be that we need to edit the way a bookmark is stored and create an additional parameter which would be pulled from here
<link rel="apple-touch-icon" href="/my_custom_icon.png"/>
Click to expand...
Click to collapse
and then the core would need to be editing to display that additional parameter if not null when the bookmark shortcut is made.
Anyone interested?
I agree about the icons: it makes a lot of sense to give web shortcuts "full citizenship".
Where did you get that cool wood wallpaper?
Thanks
The background (the document with the earth on) is determined by the the image ic_launcher_shortcut_browser_bookmark.png in the drawables folder of Browser.apk and is easily changed if you know how (any themer does). The additional icon (the Wave logo) is added (by Launcher(?)) to the general bookmark icon if the site has a favicon.
/Mats
I know this isn't a resolve, but I just use Better Cut to change the icon to a custom icon I made or found. That's why my browser looks like Chrome, etc..
i love sweet icons like that
(big and cool)
ZilverZurfarn said:
The background (the document with the earth on) is determined by the the image ic_launcher_shortcut_browser_bookmark.png in the drawables folder of Browser.apk and is easily changed if you know how (any themer does). The additional icon (the Wave logo) is added (by Launcher(?)) to the general bookmark icon if the site has a favicon.
/Mats
Click to expand...
Click to collapse
Great!
However a themer is just swapping out png's correct? Not actually writing code to pull the png from different places depending on certain properties of the target?
Is it possible to not only save the favicon but also to store the custom_icon if available and then have the launcher display that instead?
PCTechNerd said:
I know this isn't a resolve, but I just use Better Cut to change the icon to a custom icon I made or found. That's why my browser looks like Chrome, etc..
Click to expand...
Click to collapse
Yea I did this little trick for a facebook shortcut. Its okay, but would work better/faster if it did it on its own.
Maybe initially, we could have the launcher display just the favicon and not the overlaid deal?
DownloaderZ said:
Great!
However a themer is just swapping out png's correct? Not actually writing code to pull the png from different places depending on certain properties of the target?
Click to expand...
Click to collapse
Correct.
DownloaderZ said:
Is it possible to not only save the favicon but also to store the custom_icon if available and then have the launcher display that instead?
Click to expand...
Click to collapse
I guess the Launcher could be persuaded to behave like that. But that's an issue for Launcher hackers, like irrenhaus: http://forum.xda-developers.com/showthread.php?t=540880
I'm afraid the favicon only would look terrible, as it's just a 16x16 image that would be resized to 48x48:
However, by changing the std shortcut png in Browser, things can be improved:
/Mats
Are there any devs interested in helping out? (man, this sounds like a desperate plea)
Wow this is a really good idea. So basically you just want to do away with the png provided by the launcher all together and have it take the iphone icon from the website and make that the shortcut image? Sounds like a fairly simple task. I can't do it, unfortunately. But it sounds like it can be done quite easily. Someone will surely pick this up eventually
BetterBookmarks
BetterBookmarks in the Market does this already. I'm not sure if the functionality is exactly what the original poster is asking for, but I think it's pretty close. Check it out- http://www.cyrket.com/package/com.android.BetterBookmarks
It's been out for quite a while, and I'm not sure how accurate the app is at finding the icons for iPhone OS anymore. From my experience, the output of the shortcuts aren't as pretty as they would be in iPhone OS, but they're a lot more functional than the default website shortcuts.
Many favicons have multiple sizes embedded for this very reason. Would be nice if the launchers could just use the bext quality one.
I had a problem with BetterCut whenever I changed the icons for bookmarks, they'd stop working.
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
R3nrut said:
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
Click to expand...
Click to collapse
What the geeze.. gimme a sample? plz?
...how to hide from appdrawer..?
R3nrut said:
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
Click to expand...
Click to collapse
How about a complete sample source code? =)
maxisma said:
How about a complete sample source code? =)
Click to expand...
Click to collapse
Sure, its way simple though.
Code:
package com.bookmark.r3nrut;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class bookmark_r3nrut extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
}
}
Anyone interested in helping me tackle this?

[APP][2.2+][UPDATED 08/23/12] SnapNotify - Roll Your Own Custom Cloud Notifications

SnapNotify – Roll Your Own Custom Cloud Notifications
What’s the point?
SnapNotify makes getting cloud-based android notifications as easy as posting to a webserver – and the entire system (including running your own server) is free!
How does it work?
SnapNotify consists of a lightweight server (powered by node.js, which you can run for free on heroku) and an android app that handles receiving notifications. It allows you to push custom notifications to all of your mobile devices, without having to learn Google Cloud Messaging or having to write your own android app.
Sample use:
Code:
$ curl -d "Test Message,SnapNotify works. yay : )" "http://YOURSERVER/message"
Produces a notification on all of your devices that looks like this:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Some Simple Use Cases:
1) A simple web scraper / monitor
- Write a script that loads a page, checks content, and notifies you upon changes
- Offloads the heavy lifting to your server
2) Server tasks
- Just tag a POST onto the end of your management scripts to be notified when time-consuming events complete
Basically, the idea is to make it easy to incorporate GCM messages / notifications into hacks that don't need an independent and full-fledged Android App.
Installation / Setup:
I've written a full setup guide with download links and source on my website, which you can find here:
http://sagark.org/snapnotify-roll-your-own-custom-cloud-notifications/
Post here if you have ideas for improvement / find it useful / etc.
Wow awesome!
Just set this up on my Galaxy Nexus by following the Heroku guide. It works great! Thanks a bunch :laugh: :good:
Sorry for the double post, but quick question: If I already have a domain name and stuff, is there a way that I can point it to the heroku server so that I don't have to remember the long subdomain? Thanks
woot_galaxy_nexus said:
Sorry for the double post, but quick question: If I already have a domain name and stuff, is there a way that I can point it to the heroku server so that I don't have to remember the long subdomain? Thanks
Click to expand...
Click to collapse
Yep, Heroku supports this functionality. You can follow the guide at the top of this page and then setup a CNAME in your DNS:
https://devcenter.heroku.com/articles/custom-domains
sagarkar said:
Yep, Heroku supports this functionality. You can follow the guide at the top of this page and then setup a CNAME in your DNS:
https://devcenter.heroku.com/articles/custom-domains
Click to expand...
Click to collapse
Thanks it worked :laugh:
Looks good so far... but you knew this question would come up:
How do we customize notifications (different icons, different sounds, launch a custom intent on click -- maybe encoded in the notification itself, etc.)? Do you have something coming to the APK and/or source code for it?
Thanks!
Awesome post!
psouza4 said:
Looks good so far... but you knew this question would come up:
How do we customize notifications (different icons, different sounds, launch a custom intent on click -- maybe encoded in the notification itself, etc.)? Do you have something coming to the APK and/or source code for it?
Thanks!
Click to expand...
Click to collapse
Yep, this'll probably come as something encoded in the POST + predefined settings (key, values) in the app. Unfortunately, school starts tomorrow so I don't have a ton of time on my hands anymore
I'll try to get it done soon though.
Update Aug 23, 2012:
For those of you running on heroku, snapnotify-server now posts to itself every 20 minutes to prevent idling. Idling wouldn't be a problem by itself, but heroku provides a read-only fs (thus no storing to registration_store), so you'd need to re-register after every recovery from idle. Preventing the idling seems to be the simplest solution at this point. After updating, everything should work as expected. Nothing should change for anyone running on their own server.
Upgrade paths:
1) Running on heroku:
Server: Obtain the new files, change settings in snapserver.settings, git add -u, git commit -m 'update', git push heroku master
App: No need to update
2) Your own server:
Server: Stop Node.js, obtain new files, change settings in snapserver.settings (notably, change the new heroku attribute to false), restart Node.js
App: No need to update
Wound up writing my own app and ditching node.js for something that'll run on a traditional webserver. I'm not that patient and wanted to customize a bunch of stuff. Thanks for the great idea/work so far!
Thanks for this OP, it's awesome Can't wait for more features
Hi,
I want to integrate your code to my app, I don't find the Android source code. Will you release it? Is it opensource?
Thank you for your help.
Followed the heroku guide. Using the curl example I always see this error in my heroku logs:
{ messageId: undefined,
canonicalRegistrationId: undefined,
errorCode: 'MismatchSenderId' }
I've tried creating a registration_store containing the long string (seen when I registered from the Android app), but same error.
Any suggestions to getting this to work?
Edit: Got it working! I had my Sender ID wrong. Thanks for the great guide!
snoopy33 said:
Hi,
I want to integrate your code to my app, I don't find the Android source code. Will you release it? Is it opensource?
Thank you for your help.
Click to expand...
Click to collapse
I'm planning on open-sourcing it once I get time to rip out admob (the revenue from ads vs having this open source, open source wins ) and clean up the code. Unfortunately, school has started so I don't have much free time.
sagarkar said:
I'm planning on open-sourcing it once I get time to rip out admob (the revenue from ads vs having this open source, open source wins ) and clean up the code. Unfortunately, school has started so I don't have much free time.
Click to expand...
Click to collapse
Well once you open source it, the community can do it for you
Sent from my GT-I9300 using Tapatalk 2
I cant seem to get a notification to my device.
I followed the setup on your site and managed to get it up, but when I browse to my heroku address I get this:
Welcome to snapnotify-server! Your server is now running at: YOUR_SERVER_ADDRESS:45961
Click to expand...
Click to collapse
I entered the correct settings in the config file, but when I enter the example, curl -d ..., I get a log in heroku saying Invalid request: 401 and syntaxerror: Unexpected token
I have changed the URL in the snapserver.settings, but I'm sure it is supposed to say the actual address?
soulcrusher said:
I cant seem to get a notification to my device.
I followed the setup on your site and managed to get it up, but when I browse to my heroku address I get this:
I entered the correct settings in the config file, but when I enter the example, curl -d ..., I get a log in heroku saying Invalid request: 401 and syntaxerror: Unexpected token
I have changed the URL in the snapserver.settings, but I'm sure it is supposed to say the actual address?
Click to expand...
Click to collapse
Are you sure you committed and pushed after changing the settings? Also, make sure you don't include http:// in the url in snapserver.settings
sagarkar said:
Are you sure you committed and pushed after changing the settings? Also, make sure you don't include http:// in the url in snapserver.settings
Click to expand...
Click to collapse
Thanks, got it to work!
I needed to use git add -u and git commit -m 'update' to get it to update. I don't have any experience with terminal commands
psouza4 said:
Wound up writing my own app and ditching node.js for something that'll run on a traditional webserver. I'm not that patient and wanted to customize a bunch of stuff. Thanks for the great idea/work so far!
Click to expand...
Click to collapse
Would you be able to share what you have done also as this sounds very interesting.

[EDUCATION] - Algoid - Learning programming with turtle and smart language !

Everyting is on the title.... lol.
Let me present you my app Algoid.
First, Algoid is a programming language designed to simplify the self apprentiship of programing. (but not at all, it is a multi-paradigm scripting language : imperative, functional (anonymous function, class first function and recursive), OOP (prototype based, multi-inheritance), Meta Object Protocol and nativelly AOP)
Second, Algoid is an IDE to edit the AL Script code with auto-completion, code snippets, formating, DEBUGGER and STEP by STEP execution mode.
Third, Algoid is a set of online documentation / tutorials directly available on the app, with automatic copy of example and exercises source code.
This is some screen shots of the app:
It is a beta version, but nearly become an 1.0 version (06th of marth, to offer to my son, it is his birthday)
Available here:
play.google.com/store/apps/details?id=fr.cyann.algoid
I hope you will enjoy it !
This is an example to demonstrate the language (functional) capabilities.
Parse a csv file on only one line of code (developpers will love it)
PHP:
set csv;
csv = "data 1.1; data 1.2; data 1.3; data 1.4\n";
csv ..= "data 2.1; data 2.2; data 2.3; data 2.4\n";
csv ..= "data 3.1; data 3.2; data 3.3; data 3.4\n";
csv ..= "data 4.1; data 4.2; data 4.3; data 4.4\n";
set values = csv.split ("\n").each (function (item) {
return item.split (";").each(function (item) {
return item.trim();
});
});
values.eachItem(function (item) {
util.log ("parsed data : [" .. item .. "]");
});
And what about Aspect Oiented Programming with Meta Object Protocol :
PHP:
set superO = object () {
set superMeth = function (s) {
util.log ("Execute SUPER method with param : " .. s);
};
};
set o = object (superO) {
set meth = function (s) {
util.log ("Execute method with param : " .. s);
};
};
set logger = function (s, decored) {
util.log ("Before decored execution");
decored(s);
util.log ("After decored execution");
};
set myO = new o;
myO.setAttribute("meth", myO.meth.decorate(logger));
myO.meth("Hi I am algoid !");
util.log ("--------");
set myO.superMeth = myO.superMeth.decorate(logger);
myO.superMeth("Hi I am algoid !");
This is some screen shots of the app:
Play Store
Available here:
I enjoy you will like it
Hi everyone,
This is the last beta version before release.
I have to speed up, the birthday of by son is in j-8.... I have 2 or 3 little things to tune yet.
Well so new version with parser example.
Play with it, it demonstrate the power of AL isioms like cascade + functionnel.
The language is able to parse CSV (with delimiter or not) in only one line.... great class (when I think the number of time I have done this in my job).
The ; at the end of line become completly optionel. My backtracking parsing expression grammar is really powerfull, it has no problem this that.
v0.4.5 BETA 23-02-2013 Last beta version before release
- new AL features examples (AOP, ducktyping, parsing, lexical closure)
- the end line semicolon is now totally optional
- array keyword is mandatory for the first one in nested arrays
- menu organisation
Well, for next version, I am working on monetizing the app. But I don't know how to do that without changing user experience.
I anyone has an idea.
So, you can find it here....
Have a nice week-end
Little question ???????
I'm thinking about the future of the app. What would you prefer as libraries:
- Gui
- Game
- Mindstorm
- Device capabilities (GPS, Gyro, Camera ect ....)
Please do not hesitate to reply.
CyaNn said:
Little question ???????
I'm thinking about the future of the app. What would you prefer as libraries:
- Gui
- Game
- Mindstorm
- Device capabilities (GPS, Gyro, Camera ect ....)
Please do not hesitate to reply.
Click to expand...
Click to collapse
looks great , and getting great reviews on play! i will return tomorrow with double thanks ( just ran out of thanks credit! )
# for me ... maybe 1 & 4 ... muchas gracias
v 0.4.5
# 1 & 4
This is great, even wife found this interesting.
Best wishes to your son!
cheers
biopsin said:
# 1 & 4
This is great, even wife found this interesting.
Best wishes to your son!
cheers
Click to expand...
Click to collapse
Thanks a lot for your replies.
Unfortunatelly, my wife does not find it interessting.... lol.
So at the moment, the score of the suvey is :
At the moment :
gui & device capabilities : 4
game : 7
mindstorm : 0
poor mindstorm....
Hello everybody,
With great excitement, I announce the official release of v1.0 Algoid.
Algoid become a donateware, free without ads, but donate if you decide that this project is worth and helpfull.
I think it is the better choise for this kind of project.
Well, I hope you will love it.:good:
Where or how can i learn this language?
Sent from my ST18i using Tapatalk 2
Hi there.
A little up to version 1.0.1 to correct a crash on certain little device (sorry for that)
Peace an code. :highfive::silly:
CyaNn
matgras said:
Where or how can i learn this language?
Sent from my ST18i using Tapatalk 2
Click to expand...
Click to collapse
Everything is on the App.
On bottom part of the screen (on splitted view), you have tutorials, language reference and inapp forum.....
best
CyaNn :cyclops:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
jasonxD said:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
Click to expand...
Click to collapse
Do you had any problem with the app ?
If yes, please indicate me : the app version, after what action it crash. Then I can correct it.
Thanks :crying:
jasonxD said:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
Click to expand...
Click to collapse
Keep cool ! :angel:
I think I have found your problem.
You have downloaded the app at 7:48 (10 minutes after I have published the app on the store) and play store take one hour to really publish the app.
So I think you have tried the 1.0.0 version which have a serious problem of crash at startup with certains devices : GT-S5360 and GT-S5570I
the v1.0.1 version was published to fix this bug. So I think you can try it again with the new version of the app (of course if you are interested)
Have a nice week-end :angel:
Some preliminar benchmarks of AL on MacOS (quad core duo)
- Python is 2.6.1, it is an interpreted language over c++
- JavaScript / Rhino is a java on the fly compiled language (I have put the optimization to maximum)
On Android platform, Javascript should have some worst performances because it cannot generate bycode yet (due to dalvik different nature than JVM)
- AL from Algoid is my pure java interpreted language
As demonstrated, AL has similar performances than python except for object creation. I don't have solution for that yet. Perhaps in a future version.
So I am excited to see what it will done on Algoid with 3d cube
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
All these tests was realized by looping each instruction 1'000'000 times. For object creation only the instruction was executed only 10'000 times.
As until does not exists on Python an equivalent was scripted (while (True) : if (cond) break)
This last month was really hard and tedious. But it was for a good cause. I have completely re-write the AL language implementation to improve drastically performances.
And what is going on beyond my expectations: 10x to 40x faster than previous version. Faster than Javascript / Rhino (about 2x).
Unfortunately slower than Python and Lua on android only. I think Dalvik VM is not as optimized as JVM is because on my MacOS AL have same performances than Python....
Nevermind ! Try to execute the 3d cube or space invader.... These programs seems to have drank too much coffy !!!! lol.
Further, you have been a lot to vote to game developpment framework !
The developpment of a game edition of this app has started.... To be continued....
hehe, I return to my weekly update frequency.....
This is the new v1.1.2 release with
- correct several scope bugs in language
- show AL exception in source code instead of unhandle exception
- algo.curve and algo.curvedPoly
- two another 3d example : 3dAlpha and 3dSpline
I hope you will like it
Find it here :
Well, I just hope it really is "child-friendly" because, though interested, I barely know anything about programming. Trying it now.

Question A newbie Android Application

I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
pax0 said:
I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
View attachment 5523271
Click to expand...
Click to collapse
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {n
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.
wpscully said:
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidnClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.
Click to expand...
Click to collapse
That's a good start, but I think you did some iOS button handling
For a button, you need to get a reference to it in your Java and assign a click listener. It won't automatically find it like Xcode by using the same name.
Code:
...
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button1);
button.setOnClickListener(view -> {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
});
...
In older Android Studio, you had to do
Code:
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
but now you can use a lambda (->) to replace the "common" stuff
the suggested solutions gives plenty of errors see below.
Hi. Speaking of Android development anybody know where can I find the C++ and Java Android development section of this forum? Thanks!
It gives plenty of errors
The sample Java program I posted in post #2 was meant to "largely replace" all the lines in MainActivity.java. It looks like you cut/pasted some of the suggested code into the middle of the existing skeleton Java code which Android Studio creates on your behalf. That approach won't work... a bit more effort is involved.
For example, there should be one and only one record in the Java file starting with the work "package". In your screen shot I see two. The second occurrence is incorrect and probably causing most of the errors. I would keep the first occurrence of package, because that's the naming that your Android Studio gave to the program. Delete the second "package com.example.my" which I think you pasted from me into the original file.
Also, there are several "import" records needed. In my post I included the only four I thought would be needed. However in your screen shot, on the second line, I see an import record with "three dots" (an ellipsis). This is Android Studio's way of hiding code from your view, which can be confusing to new users. You should mouse-click on those three dots to expose the hidden code. Then make sure there are no duplicate import records, when comparing what was originally in the file with what you cut/pasted.
I sent a private message to you with a link to my example code. It might work for you if you copied the folder into the same location you save your Android Studio projects. Of course, I can't be sure it will work. That's why I thought it best to include just a few lines of code in my original post.
Naming of things in Android Studio matters. I called my button "button" and my onClick "button1" and it must match eXaCtLy in the XML file and the Java code. (Case matters.) I can't see all your code so you'll need to ensure the naming matches exactly. (It's intuitively better if you name your button more appropriately... like "submit" if that's what the button is supposed to do.) Also, the number of braces { } will matter, as they indicate the structure of the program in Java.
In closing, it's very hard to explain all the nuances of this development environment through posting on XDA. Which is why it may be worth your time to run through the tutorial from Google. The tutorial creates a very simple application, but it also shows a lot of what I think you want to do, which is layout an end-user interface and have a button which when pressed will go off and do some additional work.
PS: I saw some errors in post 2, which I've cleaned up. A colon and the oh was interpreted as an emoticon. Ugh.
There's a learning curve involved here... learning Android Studios. If you can figure it out you might be able to earn a good living! I confess it's too hard for me. ;-)
pax0 said:
the suggested solutions gives plenty of errors see below.
View attachment 5523855
Click to expand...
Click to collapse
Your best bet is to start small. Download an example project from an online tutorial. The ones from Google are typically garbage. Plenty of sites include a sample with their getting started.
Make a small change and see what happens when you run it. Try a bigger change next. Try adding something. Try starting a new project. Try adding your stuff to that. Next thing you know, you're explaining it to the next person.
Admittedly, this isn't a section really made for learning the basics of app development. It's more focused on one device. General will be more help.

Categories

Resources