Confused about how to evolve from (very) basic Android Development - Online Courses, Schools, and Other External Resour

Hello.
I followed all the New Boston Android videos, did everything, understood everything.
I tried to create a basic RSS feed reader, in order to better incorporate some concepts I learned in the New Boston videos (http processing, xml processing, adapting the content to lists, custom lists, etc). When I got to pass the information from the http processed data to xml parser and the list, that's when I got too much confused and knew I didn't have enough knowledge.
Then I tried to do some "Shopping List Manager" (just like OI Shopping, a bit adapted more to my taste), in order to learn.
However, again, when I neededto pass information to other objects in other classes or something like that, I get confused and don't know what to do.
So I bought CommonsWare book, "The Busy Coder's Guide to Android", which I have the latest version (5.1) and I'm reading, but I don't like to advance when I don't fully understand something. This time I'm stuck on the Action Bar part, more precisely this one:
Code:
private void configureActionItem(Menu menu) {
EditText add=
(EditText)menu.findItem(R.id.add).getActionView()
.findViewById(R.id.title);
add.setOnEditorActionListener(this);
}
I know this will seem very basic to many of you, but I get really confused on all this calls, returning results and more calls.
I don't have a background on OOP, except when I worked with PHP frameworks like Symfony, I work usually with direct task programming (scripting, automation, etc), as I am a Linux System Administrator, so my code is mainly scripting and web interface building (Python, Shell Script, PHP, Javascript, etc).
Can anybody explain what can I do to better understand this? It's just lack of practice and in time I'll understand better? Is it OOP lack of knowledge/practice? Or is it Java lack of knowledge/practice?
Thanks a lot for all your help.

Maybe the best approach is to get some face time with a person who is more experienced and have him explain to you the concept you have trouble with while focusing on the parts you don't grasp. A real human has this flexibility to do a "targeted strike" unlike a tutorial or a book that has no idea where in particular the student may get confused.
For this particular issue, the issue can be summarized as follows. Let's say you have an object call a function:
Code:
orange.peel();
This should be relatively straightforward. The next level of complexity is the fact that obj is just a variable representing an object, and in fact we can substitute anything else that evaluates to an object (i.e.: after it runs, you end up with an object). For example these all are legal ways to call the method as long as types match:
Code:
(new Orange()).peel();
(shouldEatSmallerOrange ? smallerOrange : largerOrange).peel();
retrieveOrangeFromBox().peel();
The last line illustrates calling some other function that returns the object, which is then used to call a second function. The final step from here is to recognize that instead of a single retrieveOrangeFromBox() we can have a chain of functions, each of which returns an object that is used to call the next function in line. For example:
Code:
findCar().accessCarTrunk().unloadBoxFromTrunk().retrieveOrangeFromBox().peel();
The names are unnecessarily verbose to illustrate how functions and their results relate to each other.

OOP + Android system
You're not that clear as to exactly what you are having a problem with, but in general, it sounds like you need to get a java book and learn the basic concepts of classes and interfaces. Since you say you have a background in PHP you could probably go pretty far just by following the Java tutorials on the Sun website. I say java because that's the target language here, any book on OOP in any language would be adequate but learning java would give you the added ability to read other people's android code examples more easily.
After that, you can learn the Android framework. You develop in the Java language but you work within the android framework. What that means is that here, for example, the action bar is provided to you by the android system, and this callback is called by the system, so it is all set up for you. But to understand what is happening, you need to understand when the system calls this method and what it does. That is the framework.
So more specifically, how can you understand this code? This method is called from another method, onCreateOptionsMenu(). OnCreateOptionsMenu() is a method in the Activity class that is called automatically by the system at a specific time. You need to read about the Activity class and the Activity lifecycle on the android developers site. If you want your activity to provide an options menu, you create it in OnCreateOptionsMenu and return it, the system will handle it from there. So back to configureActionItem(Menu menu), here you are passing in the menu object, which contains MenuItem objects, which the system uses to populate the menu (either on the action bar, or when you hit the menu button, depending on the android version). Each MenuItem object has a view that is associated with it (usually created in an XML file).
One thing that may be hard to understand is that all these calls are chained, so if you don't know what they are returning you don't know where to look for help. It's easier if you separate the calls out. Here, the documentation is your friend. If you look at the Menu class on the android dev site, you see that findItem() returns a MenuItem. So then you look up MenuItem, and you see that getActionView() returns a View. Look at the View class, and you can see findViewById() returns another view (a sub-view that is contained within this view). so when you look at it all together, unchained:
Code:
private void configureActionItem(Menu menu) {
MenuItem mi = menu.findItem(R.id.add);
View parentView = mi.getActionView();
EditText add = (EditText)parentView.findViewById(R.id.title);
}
findViewById returns a View, but you know that the view known by the id R.id.title is an EditText view, and you want to use it as an EditText, so you have to cast the View to an EditText (which is a subclass of View) so that the compiler knows that it is an EditText type of view. That's what the (EditText) is doing in front of the findViewById call. To understand that you need to read about subclassing and strongly-typed programming languages. PHP is weakly-typed, so that might be new to you.
finally, you call setOnEditActionListener on the EditText. OnEditActionListener is an interface that you have implemented in this class. An interface defines a common set of methods that are guaranteed to be present in whichever class has implemented it. So when you set the OnEditActionListener to this, (this means the current instance of this class), the EditText will hold on to the "this" object and it knows that it can call a certain set of methods on it. What are those methods? look up the OnEditActionListener interface in the docs:
it only has one method,
Code:
public abstract boolean onEditorAction (TextView v, int actionId, KeyEvent event);
so somewhere in this class, you will have this method defined and this is where you put code that you want to run when the EditText triggers this action. I assume this get called when the user touches the EditText.
It's really not going to be easy to work with android if you don't have a basic knowledge of OOP, specifically classes, inheritance, and interfaces. Also, knowing how java implements these concepts will help a lot. Then you can use your book to learn the Android framework.
GreenTuxer said:
Hello.
I followed all the New Boston Android videos, did everything, understood everything.
I tried to create a basic RSS feed reader, in order to better incorporate some concepts I learned in the New Boston videos (http processing, xml processing, adapting the content to lists, custom lists, etc). When I got to pass the information from the http processed data to xml parser and the list, that's when I got too much confused and knew I didn't have enough knowledge.
Then I tried to do some "Shopping List Manager" (just like OI Shopping, a bit adapted more to my taste), in order to learn.
However, again, when I neededto pass information to other objects in other classes or something like that, I get confused and don't know what to do.
So I bought CommonsWare book, "The Busy Coder's Guide to Android", which I have the latest version (5.1) and I'm reading, but I don't like to advance when I don't fully understand something. This time I'm stuck on the Action Bar part, more precisely this one:
Code:
private void configureActionItem(Menu menu) {
EditText add=
(EditText)menu.findItem(R.id.add).getActionView()
.findViewById(R.id.title);
add.setOnEditorActionListener(this);
}
I know this will seem very basic to many of you, but I get really confused on all this calls, returning results and more calls.
I don't have a background on OOP, except when I worked with PHP frameworks like Symfony, I work usually with direct task programming (scripting, automation, etc), as I am a Linux System Administrator, so my code is mainly scripting and web interface building (Python, Shell Script, PHP, Javascript, etc).
Can anybody explain what can I do to better understand this? It's just lack of practice and in time I'll understand better? Is it OOP lack of knowledge/practice? Or is it Java lack of knowledge/practice?
Thanks a lot for all your help.
Click to expand...
Click to collapse

Thanks a lot for your help. I also think my issue is with OOP, but I needed the opinion of people with more knowledge.
I understand very well what you said about onCreateOptionsMenu(), why and when is called, Activity class, lifecycle, etc.
Those things I understand without any problem. I also understand the basics of OOP, but I don't know almost nothing about Interfaces and I don't have almost any experience with inheritance, although I understand it.
I think I'm just confused because I haven't worked very long with OOP. I just don't know if I should invest in something like reading and testing something like Thinking in Java, or just practice more and more Android Development.

Related

how to start programming android?

Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
smartuse said:
Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
Click to expand...
Click to collapse
You may want to start with learning java; See here: http://mobile.tutsplus.com/tutorials/android/java-tutorial/. You may also want to learn C/C++. Take a browse around here: http://developer.android.com/guide/basics/what-is-android.html.
smartuse said:
Hello guys,
I've never programmed before and I wish to learn programming android apps. I really don't know how to start, what should I learn first. I need your help on how to start, your suggestions.
Thank you very much
Click to expand...
Click to collapse
You'll also need the android sdk and I believe eclipse is a good bit of software.
Sent from my HTC EVO 3D X515m using XDA App
Android Application Development -o'Reilly
Don't understand!
I looked at linkes you have advised, but really don't understand some things: why used paranthesys ant other signs. I mean I understand that there is a syntax but I don't understand for example why used this type of paranthesis "()" but not this type "{}".
For example, I dont clearly understand this code
public class Cat {
private String mCatName;
Cat(String name) {
mCatName=name;
}
public String getName() {
return mCatName;
};
public void setName(String strName) {
mCatName = strName;
};
}
I can't find the explanation. I need a course from the begining. What do you recommend for me, friends?
Thank you guys!
This is the Syntax: get used to it, you can't change it anyway...
PHP:
//Make a class called Cat
public class Cat {
//set up a variable, type:String, Name:mCatName
private String mCatName;
//Constructor (method which runs by default)
Cat(String name) {
mCatName=name;
}
//Public: it can be called from everwhere (even other classes or programs)
//Method name: getName.
//It simply returns the content of the variable mCatname;
public String getName() {
return mCatName;
};
//Public: it can be called from everwhere (even other classes or programs)
//Method name: setName
//It sets the variable mCatName to the value of the input variable strName
public void setName(String strName) {
mCatName = strName;
};
}
This code is a class called Cat.
It got a String which represents the Cat's name. It is set to "name" by default.
With the methods getName and setName you can either output or change the name of the Cat.
This is very basic Java. You won't learn Java in a day, just learn bit for bit.
Thanks
But tell me please, how did you started programming? What was or from which source you started first. What were your first steps?
May be it will help me, because I don't know anything in programming.
Thank you
I started with html (not a real programing language, but helpful though)
Then we did some basics in school (Pascal, basic, .net, java) and i learned PHP and more Java in my free time.
Once you learn one programing language its rather easy to switch.
Java is a good base to start with.
There are tons of tutorials on the Internet which are great for beginners. I cant recommend you a specific, i only know German ones.
I'm going to post the book that I was taught from. I can't vouch for other books, they may be better - however the person who wrote this book was a lecturer at my university and he handed out photocopies of this book as we went through the module, while the book was still being written.
It was ammended based on feedback from a number of years of students and the parts of the language and concepts they found difficult. When I went into Uni I had no programming background beyond dabbling very lightly into HTML/PHP.
The book has exercises in it, as will any other book or online guide you find, I highly recommend attempting all of them as you progress.
http://www.amazon.co.uk/Java-Just-Time-John-Latham/dp/1848900252/ref=tmm_pap_title_0
Yes, I know it costs actual money, but for a going from complete beginner -> understand Java and its concepts well enough to begin thinking about putting it on your CV, I don't think that's such a bad thing - and he's deliberately put it at a cheap price point aimed at students, it should be 3-4x that amount to bring it in line with other university textbooks that are much less helpful.
smartuse said:
But tell me please, how did you started programming? What was or from which source you started first. What were your first steps?
May be it will help me, because I don't know anything in programming.
Thank you
Click to expand...
Click to collapse
I used a book called Object First with Java, BlueJ...
BlueJ is the IDE (where you type the code in to make programs) and its free.
Java is the language, we could talk you through the code above, but its better you learn it yourself, and then you will be able to read the code above.
Look into what Object Oriented Languages are, but tbh, that Book can be found online, its not cheap but I found it rather good!
http://www.amazon.co.uk/Objects-Fir...5628/ref=sr_1_1?ie=UTF8&qid=1325806069&sr=8-1
An amazon link to the book, hope this helps!
Thanks
Thank you, guys!
I'll try to find more information about Java online. Thank you all very much!
Also, look on you tube for "the new Boston" he makes some good programming videos
Which is difference between SDK and Oracle ?
I want to know which is difference between SDK and Oracle ?
Please help me I am new here and want to start programming.

Programming question.

Hi I not sure if I'm posting this in the correct section.
Just have a quick question.
In my java android application code I have created and instance of MapView class like this:
MapView mapView = (MapView) findViewById(R.id.mapview);
What does the (MapView) do compared when you normally create an instance of a class like this:
MapView mapView = new MapView(parameters);
Thanks.
The second one is calling constructor with parameter.I am not sure ,but the first one seems like member function calling with casting .
HTC Sense 3.5, Android 2.3.5
Thanks for answering! I tried searching the web for an explanation but not easy to find.
Cheers!
Well... the first one won'k work unless you have a layout which contains a MapView called "mapview".
So first of all you should build your xml layout file.
You can use MapView mapView = new MapView(parameters) and do it all programmatically.. which is definitely harder.
Btw the "Android software development" section would be more appropriate for this question.
Just to elaborate a bit more...in Java, most of the data you work with are types of Objects. The blueprint for the type of Object is called a class. When developing a new Class, you could define this new type of Object from scratch or you could Extend an existing one.
For example, when they whipped up the MapView class, they probably decided that "you know what...MapView's are sort of like other Views (they have gravity, padding, an id, perhaps a position, a border, etc)" and decided to define a skeleton class called View which maps out the aspects that are common to all Views. They likely then made MapView extend View, overriding or adding any aspects that make MapView unique.
So, where am I going with this...back to your code snippet, there's a function called getViewById(id) that--if you look at its definition--is set to return a View. If you just tried to use the result of this function like a MapView, you would run into problems because the Java compiler would have no way of knowing under which circumstances (ie. with which ID) the returned view would actually be a MapView. In these situations where you want to tell the compiler that you want to treat an object like some other type of object, you need to cast the reference to the object. You do this by putting the type you want in parentheses and to the left of the reference you want to cast.
For example, if you made a variable of type View (View mv) and are using it to refer to something you known is a MapView ( View mv = new MapView() ), to treat it like a MapView you need to cast it ( (MapView mv).aMethodUniqueToMapView() ). Keep in mind that unless there's no way an reference to one type could contain an object of another, the compiler will allow the cast. This means that at run time there's a chance you'll get an Exception (a ClassCastException). In certain situations, this is something you'll need to handle but in this case, you're usually good to go as you know for certain the ids you assigned to your views.
Hope this didn't put you to sleep
- chris
Thank you both for answering! =)
Chris or ctttt. Your explanation did not but me to sleep, you explained just what I was asking about! I have done java for only 1 year, and just started programming for my phone, so when I saw the (MapView) casting when you created an instance of a class i just wanted to know how that worked since I haven't seen it being done before =).
Thanks so much for clearing that up =)
Cheers
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A

Learn C programming!!!! HELP DEVELOPERS!!!!

This is a thread made for learning c programming and making ourselves useful in this developing site and take part or help the developers for the making or the discovery of wonderful or let's say useful modifications​
ANY HELP FROM ANY MEMBER IS APPRECIATED
whoever wants to learn and help others in developing is welcome . we want as many members as possible so friends please come learn and contribute ..... currently this thread is being hosted by:-
Senior Member badadroid lover;and
Member billpao
Please share your knowledge with all of us and try and learn more.... its an open thread.
introduction
Turbo C++ Integrated Development Environment​
IDE is nothing but Integrated Development Environment in which one can develop, run, test and debug the application. The Turbo C++ IDE appears as shown in figure.
The C Developing Environment is a screen display with windows and pull-down menus. The program listing, error messages and other information are displayed in separate windows. The menus may be used to invoke all the operations necessary to develop the program, including editing, compiling, linking, and debugging and program execution. If the menu bar is inactive, it may be invoked by pressing the [F10] function key. To select different menu, move the highlight left or right with cursor (arrow) keys. You can also revoke the selection by pressing the key combination for the specific menu.
Invoking the Turbo C IDE
The default directory of Turbo C compiler is c:\tc\bin. So to invoke the IDE from the windows you need to double click the TC icon in the directory c:\tc\bin.
The alternate approach is that we can make a shortcut of tc.exe on the desktop.
Opening New Window in Turbo C
To type a program, you need to open an Edit Window. For this, open file menu and click “new”. A window will appear on the screen where the program may be typed.
Writing a Program in Turbo C
When the Edit window is active, the program may be typed. Use the certain key combinations to perform specific edit functions.
Saving a Program in Turbo C
To save the program, select save command from the file menu. This function can also be performed by pressing the [F2] button. A dialog box will appear asking for the path and name of the file.Provide an appropriate and unique file name. You can save the program after compiling too but saving it before compilation is more appropriate.
Making an Executable File in Turbo C
The source file is required to be turned into an executable file. This is called “Making” of the .exe file. The steps required to create an executable file are:
1. Create a source file, with a .c extension.
2. Compile the source code into a file with the .obj extension.
3. Link your .obj file with any needed libraries to produce an executable program
All the above steps can be done by using Run option from the menu bar or using key combination Ctrl+F9 (By this linking & compiling is done in one step).
Compiling and linking in the Turbo C IDE
In the Turbo C IDE, compiling and linking can be performed together in one step. There are two ways to do this: you can select Make EXE from the compile menu, or you can press the [F9] key
Correcting Errors in Turbo C
If the compiler recognizes some error, it will let you know through the Compiler window. You’ll see that the number of errors is not listed as 0, and the word “Error” appears instead of the word “Success” at the bottom of the window. The errors are to be removed by returning to the edit window. Usually these errors are a result of a typing mistake. The compiler will not only tell you what you did wrong, they’ll point you to the exact place in your code where you made the mistake.
Executing a Programs in Turbo C
If the program is compiled and linked without errors, the program is executed by selecting Run from the Run Menu or by pressing the [Ctrl+F9] key combination.
Exiting Turbo C IDE
An Edit window may be closed in a number of different ways. You can click on the small square in the upper left corner, you can select close from the window menu, or you can press the Alt+F3 combination. To exit from the IDE, select Exit from the File Menu or press Alt+X Combination.
here is the download link
I want to suggest some C programming books:
For completely starters:
C Programming A Modern Approach
Learn C The Hard Way
Deep C Secrets
For guys that have a few experience:
The C Programmin Language ( from the C editors )
C: A Reference Manual
The C Puzzle Book
---------- Post added at 10:51 PM ---------- Previous post was at 10:17 PM ----------
We have started a new C Team for starters. Anyone that want to learn C or know a few things for C can join here. We prefere users that want to contribute at badadroid project. If many members come I will make a private chat room fot the team that we will share our ideas,questions,problems etc. and we will talk of course.
The members at team now are:
billpao, badadroid lover , karimdag
If someone interests post it here or send me message!
Maybe 1 project to start...
Screenlock problem on Wave II...
Maybe minimum requirement, to know which files are involved from source code...
I have NOTHING to contribute, because no Programming skills...
Best Regards
I want to learn C too !
Sent from my GT-S8500 using xda app-developers app
adfree said:
Maybe 1 project to start...
Screenlock problem on Wave II...
Maybe minimum requirement, to know which files are involved from source code...
I have NOTHING to contribute, because no Programming skills...
Best Regards
Click to expand...
Click to collapse
Screen lockfix is really challenging for us!
karimdag said:
I want to learn C too !
Sent from my GT-S8500 using xda app-developers app
Click to expand...
Click to collapse
If you are going to start C I will put you on the team
---------- Post added 6th April 2013 at 12:05 AM ---------- Previous post was 5th April 2013 at 11:44 PM ----------
New member added karimdag !
badadroid lover said:
This is a thread made for learning c programming and making ourselves useful in this developing site and take part or help the developers for the making or the discovery of wonderful or let's say useful modifications​
ANY HELP FROM ANY MEMBER IS APPRECIATED
whoever wants to learn and help others in developing is welcome . we want as many members as possible so friends please come learn and contribute ..... currently this thread is being hosted by:-
Senior Member ash009;
Member badadroid lover;and
Member billpao
Please share your knowledge with all of us and try and learn more.... its an open thread.
Click to expand...
Click to collapse
Seriously guys, I have been following especially the modem driver development for some time, and I can tell you it is not my missing experience in the c language that cause the lack of understanding of what is going on under the hood. It is hard for me to write this, but I would not recommend starting with c as a programming language at all (the void pointers still make me go crazy :]). The code has grown with the development and is in the current state, how should I put it, not very developer friendly.
You can hate me for that, but in my opinion there is no way on earth a beginner can contribute to the implementation without making it even less readable or transform it into a complete patchwork rug.
Don't get me wrong, I love your encouragement, but lets be realistic: without some kind of documentation only the contributers know what, how and why they do what they are doing.
Hats off to Volk, Rebellos and everyone involved!
DieterM75 said:
Seriously guys, I have been following especially the modem driver development for some time, and I can tell you it is not my missing experience in the c language that cause the lack of understanding of what is going on under the hood. It is hard for me to write this, but I would not recommend starting with c as a programming language at all (the void pointers still make me go crazy :]). The code has grown with the development and is in the current state, how should I put it, not very developer friendly.
You can hate me for that, but in my opinion there is no way on earth a beginner can contribute to the implementation without making it even less readable or transform it into a complete patchwork rug.
Don't get me wrong, I love your encouragement, but lets be realistic: without some kind of documentation only the contributers know what, how and why they do what they are doing.
Hats off to Volk, Rebellos and everyone involved!
Click to expand...
Click to collapse
Also mind haw grown ! Now we are able to do what ever we want to but of course we need to want to do what we do. And even if the first steps will be very hard i think all of us will do his best therefore learning C won't be used only in this project we will be able to use it in many others and even creating our own !
"If we want so we can"
Edit 2 : ''my..experience in the C Language" so this mean that you already learned it. So could you please help us by giving us some other refrences : Books, websites, videos..
Sent from my GT-S8500 using xda app-developers app
DieterM75 said:
Seriously guys, I have been following especially the modem driver development for some time, and I can tell you it is not my missing experience in the c language that cause the lack of understanding of what is going on under the hood. It is hard for me to write this, but I would not recommend starting with c as a programming language at all (the void pointers still make me go crazy :]). The code has grown with the development and is in the current state, how should I put it, not very developer friendly.
You can hate me for that, but in my opinion there is no way on earth a beginner can contribute to the implementation without making it even less readable or transform it into a complete patchwork rug.
Don't get me wrong, I love your encouragement, but lets be realistic: without some kind of documentation only the contributers know what, how and why they do what they are doing.
Hats off to Volk, Rebellos and everyone involved!
Click to expand...
Click to collapse
hey man everything doesn't happen in a shot every thing needs to get started and this is a starting as we might end up helping the devs..... btw our learning speed of course is pacing up... as we are working as a team...... and it would even be better if people (inc. you) would share whatever you know .... and also help devs to whichever extent....... we will do our best.... maybe you also will....i don't know.... i just know that is good to ...... and we are running on the right track......
adfree said:
Maybe 1 project to start...
Screenlock problem on Wave II...
Maybe minimum requirement, to know which files are involved from source code...
I have NOTHING to contribute, because no Programming skills...
Best Regards
Click to expand...
Click to collapse
there
DieterM75 said:
This should be the driver itself:
https://raw.github.com/Rebell/andro...ellybean/drivers/video/samsung/s3cfb_lg4573.c
I could also find some setup methods related to the display driver in the following module:
https://raw.github.com/Rebell/andro...e/jellybean/arch/arm/mach-s5pv210/mach-wave.c
Simply search for "S8530" and you will find pretty interesting parts
Just found another one:
https://raw.github.com/Rebell/andro...ean/arch/arm/mach-s5pv210/wave-panel-lg4573.c
Still no clue why gpios are set the way they are...
Click to expand...
Click to collapse
everyone check these :-
C Programming Tutorial for Beginners 1
C Programming Tutorial for Beginners 2 (Part 1): Using Variables With C
C Programming Tutorial for Beginners 2 (Part 2): Using Variables With C
C Programming Tutorial for Beginners 3 (Part 1): Programming in C with Strings and Char Data Type
C Programming Tutorial for Beginners 3 (Part 2): Programming in C with Strings and Char Data Type
C Programming Tutorial for Beginners 4 (Part 1): Programming in C with Conditionals: IF/ELSE/ELSE IF
C Programming Tutorial for Beginners 4 (Part 2): Programming with Conditionals: IF/ELSE/ELSE IF
next step
A Simple C Program​
Every C program must have one special function main (). This is the point where execution begins when the program is running. We will see later that this does not have to be the first statement in the program, but it must exist as the entry point. The group of statements defining the main () enclosed in a pair of braces ({}) are executed sequentially. Each expression statement must end with a semicolon. The closing brace of the main function signals the end of the program. The main function can be located anywhere in the program but the general practice is to place it as the first function.
Here is an elementary C program.
main ()
{
}
There is no way to simplify this program, or to leave anything out. Unluckily, the program does not do anything. Following the "main" program name is a couple of parentheses, which are an indication to the compiler that this is a function. The 2 curly brackets { }, properly called braces, are used to specify the limits of the program itself. The actual program statements go between the 2 braces and in this case, there are no statements because the program does absolutely nothing. You will be able to compile and run this program, but since it has no executable statements, it does nothing. Keep in mind however, that it is a legal C program.
main ( ) function should return zero or one. Turbo C accepts both int and void main ( ) and Turbo C coders use both int and void main ( ) in their programs. But in my belief, void main ( ) is not a standard usage. The reason is, whenever a program gets executed it returns an integer to the OS. If it returns 'zero', the program is executed successfully. Otherwise it means the program has been ended with error. So main ( ) shouldn't be declared as void.d as void.
main( ) should be declared as
int main( )
{
……………..
……………..
return 0 ;
}
.For a much more interesting program, load the program
int main ()
{
printf (“Welcome to C language”);
return 0;
}
and display it on your monitor. It is same as the previous program except that it has one executable statement between the braces.
The executable statement is another function. Again, we won't care about what a function is, but only how to use this one. In order to output text to the monitor, it's placed within the function parentheses and bounded by quotes. The end result is that whatever is included between the quotes will be showed on the monitor when the program is run.
Notice the semi-colon; at the end of the line. C uses a semi-colon as a statement terminator, so semi-colon is required as a signal to the compiler that this line is complete. This program is also executable, so you'll be able to compile and run it to see if it does what you think it should. With some compilers, you may get an error message while compiling, indicating that the function printf () should have a prototype.
#include<stdio.h>
#include<conio.h>
int main ()
{
printf (“Welcome to C language”);
return 0;
}
Here you'll be able to see #include at the beginning of the program. It is a pre-processor directive. It's not a part of our program; it's an instruction to the compiler to make it do something. It says the C compiler to include the contents of a file, in this case the system file stdio.h. This is the name of the standard library definition file for all Standard Input Output. Your program will almost certainly want to send stuff to the screen and read things from the keyboard. stdio.h is the name of the file in which the functions that we want to use are defined. A function is simply a group of related statements that we can use later. Here the function we used is printf . To use printf correctly C needs to know what it looks like, i.e. what things it can work on and what value it returns. The actual code which performs the printf will be tied in later by the linker. Note that without the definition of what printf looks like the compiler makes a guess when it sees the use of it. This can lead to the call failing when the program runs, a common cause of programs crashing.
The <> characters around the name tell C to look in the system area for the file stdio.h. If I had given the name "abc.h" instead it would tell the compiler to look in the current directory. This means that I can arrange libraries of my own routines and use them in my programs.
Imagine you run above program and then change it and run it again you may find that the previous output is still stucked there itself, at this time clrscr(); would clear the previous screen.
One more thing to remember while using clrscr() is that it should be called only after the variable declaration, like
int p,q,r;
clrscr()
Here is an example of minimal C program that displays the string Welcome to C language (this famous example included in all languages ​​moreover been done originally in C in 1978 from the creators of the language, Brian Kernighan and Dennis Ritchie) Example
#include<stdio.h>
#include<conio.h>
int main ()
{
clrscr();
printf (“Welcome to C language”);
return 0;
}
When you execute above program you won’t see ‘Welcome to C language’ on the console because the screen will just flash and go away .If you want to see the line you can use getch() function just below the printf() statement. Actually it waits until a key is pressed.
Identifiers​
Identifiers are the names that are given to various program elements such as variables, symbolic constants and functions.Variable or function identifier that is called a symbolic constant name.
Identifier can be freely named, the following restrictions.
Alphanumeric characters ( a ~ z , A~Z , 0~9 ) and half underscore ( _ ) can only be used.
The first character of the first contain letters ( a ~ z , A~Z ) or half underscore ( _ ) can only be used.
Case is distinguishable. That is, word and WORD is recognized as a separate identifier.
Reserved words are not allowed. However, part of an identifier reserved words can be included.
Here are the rules you need to know:
1. Identifier name must be a sequence of letter and digits, and must begin with a letter.
2. The underscore character (‘_’) is considered as letter.
3. Names shouldn't be a keyword (such as int , float, if ,break, for etc)
4. Both upper-case letter and lower-case letter characters are allowed. However, they're not interchangeable.
5. No identifier may be keyword.
6. No special characters, such as semicolon,period,blank space, slash or comma are permitted
Examples of legal and illegal identifiers follow, first some legal identifiers:
float _number;
float a;
int this_is_a_very_detailed_name_for_an_identifier;
The following are illegal (it's your job to recognize why):
float :e;
float for;
float 9PI;
float .3.14;
float 7g;
Keywords​
Keywords are standard identifiers that have standard predefined meaning in C. Keywords are all lowercase, since uppercase and lowercase characters are not equivalent it's possible to utilize an uppercase keyword as an identifier but it's not a good programming practice.
Points to remember
1. Keywords can be used only for their intended purpose.
2. Keywords can't be used as programmer defined identifier.
3. The keywords can't be used as names for variables.
The standard keywords are given below:
Data Types​
C offers a standard, minimal set of basic data types. Sometimes these are called "primitive" types. A lot of complex data structures can be developed from these basic data types. The C language defines 4 fundamental data types:
character
integer
floating-point and
double floating-point
This data types are declared using the keywords char,int,float and double respectively. Typical memory requirements of the basic data types are given below
@Thread:
Good idea.
I recommend this tutorial - http://www.cprogramming.com/tutorial/c-tutorial.html
And of course http://www.google.com
To develop Android/Linux kernel you need... well - Linux host machine. For the begginers Ubuntu is good choice. Shell commands are google'able.
You also need knowledge about GIT. So http://try.github.com waits.
@adfree:
I concur that fixing Wave2 LCD wakeup would be good first "task".
@DieterM75:
I started C++ coding with practically falling into thing called "Open Tibia Server".
I started ARM assembler with creating FOTA bootloader.
Everything is for people, thing is I was spending up to 8-10hours daily when learning new things. To understand certain things there's just need to remember that it was all created by humans. Smart humans. And it has its technical limitations.
You are right about the files used
arch/arm/s5pv210/mach-wave.c <- Wave platform startup and operational code, putting it all together and loading drivers for most of the stuff onboard, there's general definition of platform data for LG4573, some GPIO config functions, etc etc.
arch/arm/s5pv210/wave-panel-lg4573.c <- more platform-dependent code, that's specifically LCD type identification routine and command sequences for certain LCD types (I can pull sequences for type 1 and 2 from bootloaders or APPS, though we haven't identified any devices actually using these typest)
drivers/video/samsung/s3cfb-lg4573.c <- platform-independent driver code for LG4573 IC
drivers/video/samsung/s3cfb.c <- platform-independent (at least in theory, there's ugly hack for S8500's AMOLED for eg. so this doesn't exactly follow the standards) code for CPU's framebuffer device.
There'll be also something in include/linux/lg4573.h or around I believe, like platform data definition etc.
What's to careful about - S3CFB is kinda "master" driver. During sleep it's first to put to sleep and it does invoke its "client" driver sleep function, that's LCD. It does also invoke some GPIO config stuff. So yeah - that's messy and not really transparent.
@badadroid lover:
Dude, don't attach images in BMP. This is just... Wrong, It's common sense to use JPG or PNG through internet.
Rebellos said:
@badadroid lover:
Dude, don't attach images in BMP. This is just... Wrong, It's common sense to use JPG or PNG through internet.
Click to expand...
Click to collapse
all right actually ummm... im sorry ..... ill use jpg now.....
Double​
Double-precision floating point numbers are also numbers with a decimal point. We know that the float type can take large floating point numbers with a small degree of precision but the double-precision double type can hold even larger numbers with a higher degree of precision.
The sizes of the double types are as follows.
Type Bytes Minimal range
doubleprecision 8 IE-38 to IE+38 with 10 digit of precision
long double 8 IE-38 to IE+38 with 10 digit of precision
char​
char is a special integer type designed for storing single characters. The integer value of a char corresponds to an ASCII character. E.g., a value of 65 corresponds to the letter A, 66 corresponds to B, 67 to C, and so on.
As in the table below, unsigned char permits values from 0 to 255, and signed char permits values from -127 (or -128) to 127. The char type is signed by default on some computers, but unsigned on others the sizes of the char types are as follows.
Type Bytes Minimal range
char 1 -127 to 127
unsigned char 1 0 to 255
signed char 1 -127 to 127
Float​ Floating point numbers are numbers with a decimal point. The float type can take large floating point numbers with a small degree of precision (Precision is simply the number of decimal places to which a number can be calculated with accuracy. If a number can be calculated to three decimal places, it is said to have three significant digits.)
Memory size : 4 bytes
Minimal range : IE-38 to IE+38 with six digit of precision
int​
An integer is a whole number (a number without a fractional part). It can be positive or negative numbers like 1, -2, 3, etc., or zero.
The sizes of the integer variables depend on the hardware and operating system of the computer. On a typical 16-bit system, the sizes of the integer types are as follows.
TYPE
Bytes
Possible Values le Values
int
2 or 4
-32,767 to 32,767
unsigned int
2 or 4
0 to 65,535
signed int
2 or 4
-32,767 to 32,767
short int
2
-32,767 to 32,767
unsigned short int
2
0 to 65,535
signed short int
2
-32,767 to 32,767
long int
4
-2,147,483,647 to 2,147,483,647
signed long int
4
-2,147,483,647 to 2,147,483,647
unsigned long int
4
0 to 4,294,967,295
here is an awesome site i have been following:- http://www.cprogrammingexpert.com/
Even though this site is french I find it good.
http://www.siteduzero.com/

[GUIDE] Programming languages alternatives for Android

Note to mods: this thread might be worth pinning! Using modern languages could highly improve code quality of Android apps.
OK, if you want native code, you can stick to C or C++, as you probably know interfacing native code with Java via JNI is neither pretty nor easy. But what about languages that compile to JVM (Dalvik/ART in Android case) that allow us to use tens of thousands of available java libraries in our projects? Java is quite nice but it's missing a lot of hot concepts available in modern languages like functional programming, duck typing and pattern matching. And as soon as you start using other JVM languages you'll discover Java is also extremely... verbose! I could use 5 Scala lines of code to do the same things I did in 50 lines of Java...
Note also that almost all of below languages handle null in a way much more civilized than Java. While in Java you would do:
Code:
if(someValue != null && someValue.someProperty!=null && someValue.someProperty.interestingString != null) doSomething(someValue.someProperty.interestingText)
In modern language you would just do:
Code:
doSomething(someValue?.someProperty?.interestingString)
Nice, eh?
And do believe me, these languages mix wonderfuly with Android API. Once you start coding in them, you won't come back to Java. Note that all of them have Android Studio plugins, that make the coding experience as easy as clicking "Install Plugin"!
So, let's start with the king:
Scala
Website: link
Getting started: link
Scala for Java developers: link
Why was it invented: Technically, Scala is a blend of object-oriented and functional programming concepts in a statically typed language. The fusion of object-oriented and functional programming shows up in many different aspects of Scala; it is probably more pervasive than in any other widely used language. The two programming styles have complementary strengths when it comes to scalability. Scala’s functional programming constructs make it easy to build interesting things quickly from simple parts. Its object-oriented constructs make it easy to structure larger systems and to adapt them to new demands. The combination of both styles in Scala makes it possible to express new kinds of programming patterns and component abstractions. It also leads to a legible and concise programming style.
A real beast of a language, I'm reading a fifth book on Scala right now, I have read tens of blog posts and I have a feeling like I haven't even scratched surface of it, although I've already incorporated Scala code into my XenoAmp project. If you're familiar with functional programming, you'll feel at home with Scala.
Let me rephrase the above paragraph: you PAINLESSLY incorporate below languages into your current project, without converting a single existing line! You just create new file that has extension different than .java!
Things like function literals, tuples, pattern matching and surprisingly flexible syntax of the language allow to create... a language within language, note very nice Scala/Android UI library named Scaloid and how it maintains its own minimal animation-only sub-language called Snails!
Scaloid activity layout example
Also read a blog post here about how can you write a clean code like this (note: NO SEMICOLONS!!! ):
Code:
Scala
findView[Button](R.id.button).onClick { view : View =>
Toast.makeText(this, "You have clicked the button", Toast.LENGTH_LONG).show()
}
instead of this:
Code:
Java
Button v= (Button) findViewById(R.id.button);
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(this, "You have clicked the button", Toast.LENGTH_LONG).show();
}
});
Kotlin
Website: link
Getting started: link
Kotlin for Java developers: link
Why was it invented:
to create a Java-compatible language,
that compiles at least as fast as Java,
make it safer than Java, i.e. statically check for common pitfalls such as null pointer dereference,
make it more concise than Java by supporting variable type inference, higher-order functions (closures), extension functions, mixins and first-class delegation, etc;
and, keeping the useful level of expressiveness (see above), make it way simpler than the most mature competitor – Scala.
A language created by creators of IntelliJ Idea (base of AndroidStudio), with Android in mind. It's also functional, syntax based on Scala syntax, but much simplier and easier to learn. Also has a tool to convert your Java code to Kotlin! So if you want to start using all hip goodies like functional programmin, patter matching, nullable expressions and operators - this is a place to start without feeling overwhelmed (by Scala)
Read what Jake Wharton (the one behind NineOldAndroids and ActionBarSherlock) thinks about Kotlin: https://docs.google.com/document/d/...bEhCqTt29hG8P44aA9W0DM8/edit?hl=pl&forcehl=1#
Ceylon
Website: link
Getting started: couldn't find a good primer, but you could figure it yourself
Ceylon for Java developers: link
Why was it invented:
to be easy to learn and understand for Java and C# developers,
to eliminate some of Java’s verbosity, while retaining its readability,
to improve upon Java's typesafety,
to provide a declarative syntax for expressing hierarchical information like user interface definition, externalized data, and system configuration, thereby eliminating Java's dependence upon XML,
to support and encourage a more “functional” style of programming with immutable objects and higher-order functions,
to provide great support for meta-programming, thus making it easier to write frameworks, and
to provide built-in modularity.
Supposedly more powerful than Kotlin, with better syntax for lambdas (function literals).
I might write a bit more about each language as soon as I start using them, so stay tuned. And share your experience with alternatives in this thread!
Gosu
Website: http://gosu-lang.github.io
Getting started: http://gosu-lang.github.io/docs.html
Its most notable feature is its Open Type System API, which allows the language to be easily extended to provide compile-time checking for things that would typically be dynamically checked at runtime in many other languages. [Wikipedia] Doesn't seem to have functional programming capabilities.
Groovy
to be continued

Xposed with shared library.

I was struggling not to make that kind of posts but as far I can see, I definitely need help in order to proceed.
I need help with hacking an app. The application in question utilizes AES encryption for some subset of web requests. As I understand, the key for encryption is generated by the app at native code level which then used for encrypting/decrypting internet traffic, using shared library. In addition to that, there is a method to fetch the encryption key, if my understanding of the process is correct.
Personally, I don't follow the whole sequence of actions it does to encode/decode data (app heavily utilizes both java, native arm code and server-obfuscated JS code so it'd a bit complicated to follow). So, I thought that it might be faster and more effective to go straight for the key, so the plan was writing xposed module which would fetch it.
I haven't developed for Android platform before so please bear with my ignorance. As I understand, if the method in shared library is called Java_<class>_<method> then it can be declared in that class and be called from there. If the library is checked using IDA Pro, you could see a bunch of method following that naming approach in Exports tab. The problem is that the key fetching method uses different naming/declaration - <ClassA>::<ClassB>::<Method> (and its export name is something like _ZN3ClassA6ClassB9MethodEv). While I have a vague idea of calling typical native class methods (Java_.... ones), I don't have a slightest idea if <Class1>::<Class2>::<method> could be called from Java code somehow.
Any help would be appreciated.

Categories

Resources