This post covers how to run android development codes directly on smartphones (not AVDs) and how to modify the “Hello World” app to create powerful apps.
1. How to run android development codes directly on smartphones?
In order to run android development codes on smartphones, we need to do two things. On the smartphone’s side, we need to launch the “USB debug mode”. On the PC’s side, we need to install the driver for the smartphone. Then we plug in the smartphone to the PC, and we can see the phone shown at the “Device View” of Eclipse. If we run the codes as “Android Application”, then we can choose to run the codes on our smartphones. If the codes executes successfully, the app will automatically show in the smartphone.
2. How to modify “Hello World” app?
There is a file “activity_main.xml” in the directory of project->res->layout. Open this file and you will find code like this.
And in the project->res->values->string.xml, you will find code like this.
Obviously, @string/hello_world in activity_main.xml refers to the content defined in the strings.xml. And the content is “Hello world!”. So if we want the app to show something different, we can change the content of hello_world or create another string like hello_world. For example, if we want to show “The Lord of Rings”, we can modify the activity_main.xml and strings.xml as follows.
We can also open the Graphical Layout of activity_main.xml to use GUI to insert texts or images to the app.
3. Some Tips
1. In AndroidManifest.xml, we can modify SDK version to let our app run in older or latest smartphones.
2. Use “Quick Access” to find the View of “File Explorer”. Under this view, we can transfer files between PCs and smartphones.
3. The R.java in the project->gen directory is automatically generated. Generally, this file will automatically refresh if we modify the project. If not, we can just delete R.java and this file will be regenerated.