Introduction To Android : Android Tutorial Linux

October 26, 2017 | Author: King | Category: Linux
Share Embed

Short Description

Description: Android Tutorials...


4   Figure 2. Android preferences panel in Eclipse. Figure 3. Android update panel in Eclipse. 5    Linking Your Phone to Your Computer    1.   Turn on your phone. 2.   Go to the home screen. 3.   Select Applications > Development and then enable USB debugging. 4.   After you have downloaded updates for the Android SDK in Eclipse above, the USB driver should have been included. Install the USB driver on your computer, following the tips on the following page: (Note: On SCIEN computers, the device file in / etc/ . . .  is already configured.) Part II: Developing Image Processing Programs for Android    Now that the Google Android SDK, the Java Runtime, and the Eclipse IDE are all set up on your computer, we are ready to start writing image processing programs that can run an Android- compatible mobile device.  Hello World Example First, we will build a simple Android program in Eclipse. This simple example will also help you to become familiar with how to create an Android project, how to (auto) compile source code, and how to run the generated executable on the mobile device. Please follow the instructions on this page to develop the “Hello World” program: http: / / devel oper. androi d. com/ resources/ tutori al s/ hel l o-worl d. html (Note: In case there are strange errors when the project is created about “”, simply add a comment line (e.g., “// dummy comment”) at the top of “gen : com.example.helloandroid :” and save the file. This will make the errors disappear.) In the external “Hello World” tutorial, they only run the “Hello World” program in an emulator. Additionally, we will now also run the program on the actual Android-based phone. Make sure your phone is properly linked to your computer. 1.   In Eclipse, select Run > Run Configurations > Android Application > HelloWorld > Target. Choose Manual for Deployment Target Selection Mode. 2.   Select Run, and in the Device Chooser dialog, select your Android-based phone. The “Hello World” program will be sent to and automatically started on your phone, and you should see the screen similar to Figure 4 on your phone. 6   Figure 4. “Hello World” program running on Android-based phone.  EE368 Viewfinder Example  Now, having grasped the fundamentals of building and running an Android application, we will create a more complicated project involving the onboard camera and real-time image processing. 1.   Create a new Android project with the following parameters. Project name: ViewfinderEE368 Check the box for Android 2.0.1 Application name: Viewfinder EE368 Package name: com.example.viewfinderee368 Check the box for Create Activity and enter: ViewfinderEE368 Min SDK Version: 6 2.   Copy the text in the following document into AndroidManifest.xml. This defines the main activities and permissions for this program. http: / / ee368. stanf ord. edu/ Androi d/ Vi ewf i nderEE368/ Androi dMani f est. xml 3.   Copy the text in the following document into src : com.example.viewfinderee368 : This defines the classes in this program. http: / / ee368. stanf ord. edu/ Androi d/ Vi ewf i nderEE368/ Vi ewf i nderEE368. j ava 4.   Check to make sure everything is copied correctly into the project. If there are compilation errors, a red X will appear in the Package Explorer. 7   5.   Select Run and in the Device Chooser dialog, select your phone. You should see something like Figure 5 on your phone. Point the camera at different objects around you to see how the mean, standard deviation, and histogram of each color channel changes dynamically. You are augmenting the viewfinder in real time! Figure 5. “Viewfinder EE368” program running on Android-based phone.  Real-time Phone Debugging in Eclipse It is actually possible to view real-time messages from the phone in Eclipse, which can be very helpful for debugging and code development. 1.   Select Window > Open Perspective > DDMS. 2.   A new tab entitled “DDMS” should appear next to the default “Java” tab. Click on the “DDMS” tab. 3.   Select Window> Show View > LogCat. The LogCat view shows a sequential list of real- time messages from the phone. In particular, error messages in red can be very useful when trying to debug a problem.
View more...


Copyright © 2017 DOCTUTS.COM Inc.