O’Reilly, Developing Android Applications

android

android

Last week, O’Reilly started a free training Android course, I had the chance to attend it, all of it, unlike some of my friends who couldn’t stay up till late night :)

I also had the chance to take notes, .. I will post the notes of the first lecture at the end of this post (its my notes, do not expect to understand everything from it because you did not write it :) )

the lecture started with the basic principles on how Android works, … you know .. the “useless things that is good to know” sort of things, than some tips on installations and some basic “flash light” program, .. and during that whole thing a lot of questions were made by the people watching the course, .. some questions are really irrelevant and useless, while others were interesting.

Before i post my notes i would like to mention my opinion about the course from the first lecture (this opinion is merely my personal opinion). It is my first time coding Android, .. but it is NOTmy first time coding :)

My opinion on Tony the lecturer

He seems to know somethings on Android, more than most of us obviously, but i am afraid that I expected the lecture to be more professional, I mean during the lecture, Tony was exploring the code and how things work, i did not find him mastering the language, … but in my opinion as long as he is ahead of us at least one step, than praise him :)

My humble opinion about the Android programming language

Android relies heavily on user-defined XML tags (or that is what i saw from the first lecture). its not a good or bad thing, .. it is just … different i guess.

It is a very interesting course and i would like to encourage anyone who has the slightest interest in developing mobile applications to attend this course

Anyways .. without further dues, … here are my notes :)

————————-

linux>Native Libraries > Run time + Dalvik VM > andriod framework (activity manager, content Provider, Location manager, Notification manager,..) > System apps (contacts, Phone Dialer, Email, Web Browser)

app: code + R resources (movie, xml, pic)

Activity: single screen. app have many activities

intent: code to accomplish a verb (call number, open contacts)

developer.andriod.com/sdk/eclipse-adt.html

package name > unique
min SDK Version, "API LEVEL", Andriod 1.5 > 3

manifest (Like in J2ME, configuration file)

main.XML have app configuration (like orientation, gravity position of the test")

String.XML
"@String/Hello" > Macros, u can use it for localization

"@String/Red" >> you can set Red= "Red hat" in String.XML

Color.XML

#FFFF0000

android:background="@color/red"

activity > screen > .java

R class generated automatically, each new resource will be added automaticallyin the R class

you can add new elements in main.xml like "button" and you can set its attributes (via XML Tags)

the @+id adds unique ID by default

in JAVA (RefFlashActivity.Java)
Button greenButton = (Button)findViewById(R.id.green_button);
greenButton.setOnClickListener(new View.OnClickListener(){...})

Intent intent = new intent(activ.this, act2.class);
startActivity(intent);

the above will change from one screen to another.

Here is answer to right to left: Google tracks issues and feature requests at Google Code's site. As of January 2010[update], the most requested ("starred") feature is the support for right-to-left languages such as Arabic and Hebrew.[90][91]

http://developer.android.com/reference/java/text/Bidi.html


——————-

Read More

Calling ASP Functions from java script

Umm i think some may get confused that isn’t it that Ajax can call server side functions from JavaScript ?? ! well thats write but i want to talk about those people who are still using Microsoft .NET 2005 and not lucky enough to get gaya or other ajax plug-in from Microsoft, or those who are still not ready to deal with Ajax and other Ajax/JavaScript plug ins such as jquery .

Most of the old .NET developer are used to have their web applications deal with post-backs but very few of them really knows how these post-backs do work. well most of the things in .NET application are done depending on client side script (JavaScript).

For that when you have a good amount of JavaScript controlling your application you need to know how to make that JavaScript call an asp function.

Before explaining how to do this first lets see why do we need it ? Well may be you will need to do something with JavaScript before calling server side codes, like validating entered data ( well i know that is a very bad example since in .NET there is a ready validating controles) a better example lets say you have created a web page that allow users to draw for example mind maps, or charts, or mouse gestures so that when user drag his mouse in a specific way there will be a specific response from your web application.

well in all of these examples JavaScript or JavaScript frameworks like jquery will be doing most of the things in the application here the decision to make a server side function call should be given to java script code.

Calling asp.NET function by JavaScript you need to do a simple trick,

Well as i found from some of my tries to get there, that you can not do it having normal form buttons you will need at least one “link button” (sure you can hide it, but NEVER make visible = false because it will be removed from the HTML code; instead apply CSS style on it that make it hidden)

visibility:hidden;

then you need to call the post back function that usually is called if you really do click that link_button and in the asp.NET code do call your asp function in the link_button event handler function.

well thats a lot of blah blah, theoretical talks, well then lets get into action then.

here i will show a very simple example (sorry i am out of creativity by now so the example will be very simple) i created a very simple page with a text box an a link button

i added a very simple response code to the link button click event in C#

well yeah this is our server side function (i told you this week i am out of creativity).

and then i added they style to hide the link button

now even in the IDE you just cannot see the link button

now the real thing is in the java script i have done a very simple and a very boring thing witch is on each button press it makes the text in the text box uppercase and if the length of text reaches to 6 it will call the server side function

i have added it just before the end of form tag


well you can see the real point is in the function __doPostBack(”,”)
which is created by Visual Studio it self you do not have to program it and it can call server side functions by its own way (well what you do not know that there are a lot of hidden fields in your page that are getting created by visual studio and are used for these kind of stuff)

and the reason i say that we must have a link button is that i found Visual studio do not create this JavaScript function __doPostBack(”,”) if we dont have link button

well thats all for today i think hope this thing (which i had to search and try a lot of things to be able to do) will help you in your projects

Read More

UPL

UPL : “Universal Programming Language“, or you can say UPL : “UPL is Programming Language:) .

It is an idea that we were thinking of for more than a year, and thanks to Yamani it is slowly coming to the reality.

The Idea
As was discussed in many blogs few weeks ago, we need to find good and intelligent ways to teach our children and “programming children” (those who are not Childs in real but newbie in programming world) about programming.

Thinking about that we can see (as we think) the two biggest obstacles faced by these two groups are:
(1) The complex syntax:
come on how many people you know were able to understand the pointer of pointer of a function that takes a reference and a pointer in C++ from the first time :) .
(2) The Language:
by language we do not mean the programming language but the “English” language (even though it is becoming the universal language now, still lots of kids have problems in English learning it. (and come on who said programming must be in “English”).

What UPL can do about that!
Well so what do UPL do exactly?
It is not the direct solution to the problem, but it is one of the keys to the solution. It is a simple engine where you can create your own programming language with your own syntax, and with the human language that you desire.

The current version of UPL support a very simple syntax that is some how look like old quick basic. There is a language file where you can replace any keyword in the (English UPL) to any other keyword in any other language or any other word in English itself , for example the keyword “Declare” could be changed to “dim” to look like visual basic more, or it can be changed to “Aref” the Arabic word the means declare, or even you can write in Arabic writing, French , Japanese, and like that it gives endless choices of creating your own language.

What happens inside the upl Editor is what ever syntax you are using it will be translated to the English up and then again the English upl is translated into JAVA (in the current version the algorithim is updated to change any syntax to Java directly) and finally java file is produced compiled and executed.

the syntax of current English UPL is very simple:



download

UPL in action(Future)
Well yes it is not in action yet (well it is still alpha, still it don’t have loops,still … , ….,….) but lets talk about future , what UPL can do when it gets into action. So lets see some possible futures for upl:
1- Engine for creating lots of educational programming language syntax in different human language scripts (English , French, japanease, ….).

2- The same engine mentioned before could be use to make programming look more like story writing for kids
(I mean after a lot of modifications) a kid will be able to write some kind of story and clicking on run will show him the story happening infront of him ( well we will need to use graphical libraries for doing so).

3- Visual animated programming ( ummm imagine this )
: a kid opens a software he drags an icon of a hummer with declare written on it then he writes “x=12” , next he will drag an icon of wondering rabbit that have if written between it ears and write “x>10”, and continue programming in this way. We can see this drag and drop will create may be html document, and there will be a translation file from that kind of html into the English upl which will be automatically translated to java and run.

Read More