Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to read an Android Project

Tags:

java

android

I searched on the net for this , but did not get a satisfactory answer. I am new ti Java and Android Programming Environment and have written small applications in Android (simple beginner level) . Now , as everyone says that , to write good programs you should (of-course program) read programs and codes written by other people. This will help you understand how others code , be able to see different coding styles. Now my question is that , if I have an android application with its source code (There are many open source projects available) how should I attempt to read the project? with what should I start reading first? The GUI things or directly run into reading the code , the activities , the services etc etc. How from just the code will I be able to track what the code intends , how its logic flows ? I have an Android phone on which I can test. I just want to know how to read the code properly to have a right grasp of what and how it is doing things.

like image 925
user3686864 Avatar asked Sep 03 '25 04:09

user3686864


1 Answers

Knowing the basics of any Android application, you can:

  • find the main activity that runs when your app starts
  • start with onCreate(), which gets called when your activity is created
  • you can set a break point there, and follow the execution of the code by stepping with debugger
  • check which variables are used in onCreate(), see where they are declared, initialised, used
  • check which methods are used in onCreate(), see where they are defined
  • check corresponding xml layout files for activities you inspect, see how elements are defined there, and how corresponding code in java is using some of them
  • you will see that the code is like puzzle, with each element co-operating with others, find their relationships
  • read, read, read, documentation is your friend
  • ...
like image 160
Melquiades Avatar answered Sep 04 '25 19:09

Melquiades