4

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.

user3686864
  • 337
  • 2
  • 5
  • 13
  • 2
    Hey buddy go to youtube and find some video tutorial that will help you with this, here your question will be downvoted by others and your question will be removed. with this I am providing you following may be usefull links : http://stackoverflow.com/questions/11386448/creating-a-new-android-project-in-eclipse – Bilbo Baggins Jun 04 '14 at 12:54
  • 1
    http://developer.android.com/training/basics/firstapp/creating-project.html – Bilbo Baggins Jun 04 '14 at 12:54
  • search on github for android projects – A.S. Jun 04 '14 at 12:56
  • hello , I know how to create an android application and have done with the basic application on the developer site , I just want to know, that , if I have a fairly complex android application source code , How should I read it ? – user3686864 Jun 04 '14 at 12:56
  • Fork a github project and try to add a small feature. I forked AdAway and am trying to add some stuff to it for example. Learned a lot about strings. – Mgamerz Jun 04 '14 at 14:37
  • Without Visual Programming, it is very hard to read others' intended logic in their programs. In the future, this problem will be solved with the help of AI and its auto diagram generation for the old codes. In programming, everything starts from somewhere and ends somewhere else but with today's approach of programming, it is hard to know what is what. It will take weeks or even month to understand a project fully. But if you have a flowchart or mindmap of that project it would be fun and easy with the very short time required to read a project to understand its flow of logic. – Eftekhari Sep 12 '19 at 11:30

1 Answers1

10

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
  • ...
Melquiades
  • 8,496
  • 1
  • 31
  • 46