Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Geräte Buttons - App Service

    Code Block
    languagejava
    themeEclipse
    linenumberstrue
    /**
     * Add a button handler, e.g. for the back button
     */
    AppService.getInstance().addBackButtonHandler(event->{
        // Do something ...
        // and consume event so that it will not be processed in the default manner by the source which originated it.    
        event.consume();
    }); 


  • Barcode-Scanner - Zugriff auf sämtliche Barcode-Scanner. Formate u.a.: QR, Data Matrix, UPC E/A, EAN 8/13, Code 128/93/39,CodeBar, ITF, RSS 14/Expanded, PDF417, MSI, Aztec

    Code Block
    languagejava
    /**
     * Use BarcodescannerService to scan a barcode.
     * Results are delivered asynchronously via callbacks.
     */
    
    /**
     * Opens the barcode scanner app.
     */
    void scan()
    {
        BarcodescannerService.getInstance().scan(this::barcodeScanned,this::onError);
    }
    
    /**
     * Success callback
     */
    void barcodeScanned(final BarcodeData barcode)
    {
        System.out.println(barcode.getFormat()+": "+barcode.getData());
    }
    
    /**
     * Error callback
     */
    void onError(final MobileServiceError error)
    {
        System.err.println(error.getMessage());
    }


  • Camera
    • Zugriff auf Foto- und Video-Funktion, Front- und Back-Camera 
    • Direkte Übertragung von Bilder und Videos 
    • Speicherung von Bilder und Videos auf dem Gerät mit späterer Weiterverarbeitung via File-Service. Optionell: Bild/Video, Front-/Back-Camera, Qualität, Dateiformat
    • Zugriff auf Bild-Bibliothek
    Code Block
    languagejava
    /**
     * Use CameraService to take pictures, videos or to choose a file from an album.
     * Results are delivered asynchronously via callbacks.
     */
    
    /**
     * Opens the camera app.
     */
    void takePicture()
    {
        final CameraOptions options = CameraOptions.takeAndReturnPicture();
        CameraService.getInstance().getPicture(options,this::pictureTaken,this::onError);
    }
    
    /**
     * Success callback
     */
    void pictureTaken(final ImageData imageData)
    {
        // do something with taken picture
    }
    
    /**
     * Error callback
     */
    void onError(final MobileServiceError error)
    {
        System.err.println(error.getMessage());
    }


  • Kontakte
    • Durchsuchen der Kontakt-Datenbank
    • Auswählen eines Kontakts
    • Bearbeiten und speichern eines Kontakts 
    Code Block
    languagejava
    /**
     * Use ContactsService to work with contacts.
     * Results are delivered asynchronously via callbacks.
     */
    
    /**
     * Shows the contact picker app
     */
    void pickContact()
    {
        ContactsService.getInstance().pickContact(this::contactPicked,this::onError);
    }
    
    /**
     * Finds contacts by name
     */
    void findContacts(String name)
    {
        final ContactFindOptions options = ContactFindOptions.byName(name);
        ContactsService.getInstance().find(options,this::contactsFound,this::onError);
    }
    
    /**
     * Success callback
     */
    void contactPicked(final Contact contact)
    {
        System.out.println(contact);
    }
    
    /**
     * Success callback
     */
    void contactsFound(final List<Contact> contacts)
    {
        System.out.println(contacts);
    }
    
    
    /**
     * Error callback
     */
    void onError(final MobileServiceError error)
    {
        System.err.println(error.getMessage());
    }


  • Dateisystem - Lesender Zugriff auf das Dateisystem des mobilen Gerätes.

  • Geolocation 
    • Aktuelle Position (Längen- und Breitengrad sowie Höhe)
    • Verfolgung der Position durch Bewegungsdaten (Richtung und Geschwindigkeit)
    Code Block
    languagejava
    /**
     * Use GeolocationService to acquire position information.
     * Results are delivered asynchronously via callbacks.
     */
    
    /**
     * Lookup the current position of the device
     */
    void getCurrentPosition()
    {
        GeolocationService.getInstance().getCurrentPosition(this::positionFound,this::onError);
    }
    
    /**
     * Success callback
     */
    void positionFound(final Position position)
    {
        System.out.println(position);
    }
    
    /**
     * Error callback
     */
    void onError(final MobileServiceError error)
    {
        System.err.println(error.getMessage());
    }


  • NFC - Lesen und schreiben von NFC-Tags

    Code Block
    languagejava
    /**
     * Use NfcService to read and write NFC tags.
     * Results are delivered asynchronously via callbacks.
     */
    
    /**
     * Start listener
     */
    void startListening()
    {
        NfcService.getInstance().startNdefListener(this::ndefListenerCallback,this::startNdefListenerSuccess,this::onError);
    }
    
    /**
     * Stop listener
     */
    void stopListening()
    {
        NfcService.getInstance().stopNdefListener(this::stopNdefListenerSuccess,this::onError);
    }
    
    /**
     * Tag read callback
     */
    void ndefListenerCallback(final Ndef ndef)
    {
        final Tag tag = ndef.getTag();
        System.out.println(tag);
    }
    
    /**
     * Listener successfully registered
     */
    void startNdefListenerSuccess(final String message)
    {
        System.out.println(message);
    }
    
    /**
     * Listener successfully removed
     */
    void stopNdefListenerSuccess(final String message)
    {
        System.out.println(message);
    }
    
    /**
     * Error callback
     */
    void onError(final MobileServiceError error)
    {
        System.err.println(error.getMessage());
    }


  • Vibration 
    • Einfache Vibration mit variabler Dauer, z.B. 1 sek.
    • Vibrations-Muster mit variabler Dauer und Pausen, z.B. Vibration 0,5 sek., Pause 0,3 sek., Vibration 0,1 sek. usw.
    Code Block
    languagejava
    /**
     * Vibrates one second
    */
    VibrateService.getInstance().vibrate(1000);
    
    /**
     * Pattern: Vibrate 500 ms, pause 250 ms, vibrate 250 ms (Android only)
    */
    VibrateService.getInstance().vibrate(500,250,250);


...