Familja Java dhe J2ME


Run in the background Run in the background



Yüklə 8,99 Mb.
səhifə7/8
tarix17.09.2018
ölçüsü8,99 Mb.
#68797
1   2   3   4   5   6   7   8

Run in the background

  • Run in the background

    • Can continue even if Activity that started it dies
    • Should be used if something needs to be done while the user is not interacting with application
      • Otherwise, a thread is probably more applicable
    • Should create a new thread in the service to do work in, since the service runs in the main thread
  • Can be bound to an application

    • In which case will terminate when all applications bound to it unbind
    • Allows multiple applications to communicate with it via a common interface
  • Needs to be declared in manifest file

  • Like Activities, has a structured life cycle





Similar to launching a regular Java app, use the launch configurations

  • Similar to launching a regular Java app, use the launch configurations

  • Specify an Android Application and create a new one

  • Specify activity to be run

  • Can select a manual option, so each time program is run, you are asked whether you want to use the actual phone or the emulator

    • Otherwise, it should be smart and use whichever one is available








Should be enabled on phone to use developer features

  • Should be enabled on phone to use developer features

  • In the main apps screen select Settings -> Applications -> Development -> USB debugging (it needs to be checked)



Used for a wide variety of developer tasks

  • Used for a wide variety of developer tasks

  • In the ‘platform-tools’ directory of the main android sdk directory

    • Recommend putting this directory and the ‘tools’ directory on the system path
  • adb.exe



Instead of using traditional System.out.println, use the Log class

  • Instead of using traditional System.out.println, use the Log class

    • Imported with android.util.Log
    • Multiple types of output (debug, warning, error, …)
    • Log.d(,)
  • Can be read using logcat.

    • Print out the whole log, which auto-updates
      • adb logcat
    • Erase log
      • adb logcat –c
    • Filter output via tags
      • adb logcat : *:S
      • can have multiple : filters
      • corresponds to debug, warning, error, etc.
      • If use Log.d(), then = D
  • Reference

    • http://developer.android.com/guide/developing/debugging/debugging-log.html


Some say you need to root the phone – that is not true

  • Some say you need to root the phone – that is not true

  • One option: Android Screen Capture

    • http://www.mightypocket.com/2010/08/android-screenshots-screen-capture-screen-cast/
    • It’s slow, but fine for screenshots of applications whose screens aren’t changing fast
    • Read their installation help, following the extra steps if need be (I had to copy adb.exe and some dll files, as they explain)


Using Google Maps in your app

  • Using Google Maps in your app

  • Setup project to use ‘Google API’ version

  • Edit Manifest file

    • To indicate the app will use maps and the internet
  • Get a maps API key

  • Note: Google Maps API can display a map and draw overlays, but is not the full Google Maps experience you enjoy on the web

    • For example, there does not seem to be inherent support for drawing routes between points (if you find it let me know)…however, you can draw lines between points and almost any type of overlay, but that’s different than street routes
    • The directions API is a web service, which is different, among several other Google web services
  • Read the Google API terms of use





Open Manifest file

  • Open Manifest file

  • Add map library tag

    • Add the ‘Uses Library’ com.google.android.maps
  • Indicate the app will access the internet

    • Add the ‘Permission’ android.permission.lNTERNET
  • End goal is to add the following two lines to XML file, under the and , respectively

    • Under the tag
      • "android.permission.INTERNET">
    • Under the tag
      • "com.google.android.maps">
  • Following is GUI way to add them





Select ‘Add’ under ‘Uses Library’ (last slide)

  • Select ‘Add’ under ‘Uses Library’ (last slide)

  • Then select ‘Uses Library at this prompt

  • Set name as: com.google.android.maps (next slide) and save








Yüklə 8,99 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə