You are here

How to build and run the HelloRepo application

This tutorial describes how to build and run the Hello application.

This tutorial assumes you have obtained the SDK source code from SkyVault's GitHub repository.

It is assumed you have already built the source code.

It also assumes you have already created a suitable Android Virtual Device (AVD) using the Android Virtual Device Manager (VDM) to run the application on, or have access to a suitable hardware device. See Google's documentation on how to do this if you have not done this before.

  1. Change into the ./samples/alfresco-mobile-android-samples-hellorepo directory for convenience.
  2. Edit the source code for HelloRepo to reflect your repository. Load the file ./src/org/alfresco/mobile/android/samples/hellorepo/MainActivity.java into your editor of choice.
  3. In your editor navigate to the code:

                
    // Modify to suit your SkyVault server installation
    String url = "http://localhost:8080/alfresco";
    String username = "admin";
    String password = "admin";
    
              
  4. Change the url, username and password values to reflect your repository.

    Attention: Note that localhost may not work when used as the address when running in the emulator. If your are running a local installation of SkyVault you can use ifconfig or equivalent tool to find your actual IP address. Your local URL may then look something like the following: http://192.167.2.61:8080/SkyVault. The other option is to try the standard AVD IP address of 10.0.2.2.
  5. In the samples/alfresco-mobile-android-samples-hellorepo/ directory, build the source code for HelloRepo with the command mvn install.

    This creates the required APK file, which will need to be installed into the simulator or real device. The APK file generated is ./target/alfresco-mobile-android-samples-hellorepo.apk. This is the HelloRepo application packaged to run in the Android environment.

  6. List potential AVDs using the command android list avd.
  7. In a new terminal window, run a suitable AVD (emulator) using the command emulator -avd [avdname], replacing [avdname] by the name of a suitable AVD.
  8. Make sure the emulator has fully booted.
  9. In the original terminal window, install the APK file using the command adb install ./target/alfresco-mobile-android-samples-hellorepo.apk
  10. In a new terminal window, invoke Logcat in order to view logging output using the command adb logcat.

    Keep this terminal window in a prominent place (ideally on a second screen) so you can view the output while interacting with the emulator.

  11. In the emulator clicks the apps icon (circle with six small squares). You will see the application you just installed listed as Sample:HelloRepo.
  12. In the emulator click on the Sample:HelloRepo app to launch it, while at the same time monitor the Logcat window.

    Check that the HelloRepo log messages are displayed as expected. You should see information about the repository such as version information. You may also see a list of documents contained in the document library of a site that may exist in the repository.

    Sample Logcat output is shown here:

              
    ...
    D/ConnectToRepo(  494): baseUrl: http://192.168.1.69:8080/SkyVault
    D/dalvikvm(  494): GC_CONCURRENT freed 404K, 6% free 9393K/9927K, paused 4ms+4ms
    D/ConnectToRepo(  494): rootFolder: Company Home
    D/ConnectToRepo(  494): repoId: e4d04995-2832-499e-b15d-5083d9a54bbc
    D/ConnectToRepo(  494): repoName: Main Repository
    D/ConnectToRepo(  494): repoDescription: Main Repository
    D/ConnectToRepo(  494): repoVersion: 4.1.0 (143)
    D/ConnectToRepo(  494): repoEdition: enterprise
    D/URL     (  494): http://192.168.1.69:8080/alfresco/service/api/people/admin/sites
    D/dalvikvm(  494): GC_FOR_ALLOC freed 20K, 6% free 9415K/9927K, paused 38ms
    I/dalvikvm-heap(  494): Grow heap (frag case) to 9.386MB for 131088-byte allocation
    D/dalvikvm(  494): GC_FOR_ALLOC freed <1K, 6% free 9543K/10119K, paused 40ms
    D/IOUTILS (  494): Stream close
    D/IOUTILS (  494): Stream close
    D/IOUTILS (  494): Stream close
    D/IOUTILS (  494): Stream close
    D/dalvikvm(  494): GC_CONCURRENT freed 409K, 6% free 9580K/10119K, paused 4ms+4ms
    D/BrowserFragment(  494): childObjects : 4
    D/dalvikvm(  494): GC_CONCURRENT freed 295K, 5% free 9698K/10119K, paused 4ms+4ms
    D/BrowserFragment(  494): ITEMS : Agency Files
    D/BrowserFragment(  494): ITEMS : Budget Files
    D/BrowserFragment(  494): ITEMS : Meeting Notes
    D/BrowserFragment(  494): ITEMS : Presentations
    D/ConnectToRepo(  494): node: Agency related files=Agency Files created by: mjackson isFolder: true
    D/ConnectToRepo(  494): node: Project finance files=Budget Files created by: mjackson isFolder: true
    D/ConnectToRepo(  494): node: Project meeting notes=Meeting Notes created by: mjackson isFolder: true
    D/ConnectToRepo(  494): node: Project presentations=Presentations created by: mjackson isFolder: true
    D/ConnectToRepo(  494): doInBackground Complete
    ...