SlideShare a Scribd company logo
HTML5 приложения за Android
Урок 07
Леон Анави
@leonanavi
leon@anavi.org
С подкрепата на:
@leonanavi
Съдържание
 Cordova plugin за геолокация
 Cordova plugin за ускорение
 Cordova plugin за камера и работа със снимки
@leonanavi
Cordova Plugins
 Допълнителни модули, които могат да се инсталират
към Cordova приложение, за да се достъпи
специфична за мобилните устройства
функционалност през JavaScript.
 Регистър за Cordova plugins:
http://plugins.cordova.io/
@leonanavi
Геолокация
 Cordova плъгин за работа с определяне на
местоположението
 Базиран на HTML5 Geolocation API:
http://dev.w3.org/geo/api/spec-source.html
 Работи за Android, iOS, BlackBerry 10, Windows Phone,
Firefox OS
 Инсталация към съществуващ Cordova проект:
cordova plugin add org.apache.cordova.geolocation
 Документация:
http://plugins.cordova.io/#/package/org.apache.cordova.geolocation
@leonanavi
Акселерометър
 Cordova плъгин за измерване на ускорението
 Работи за Android, iOS, BlackBerry 10, Windows Phone,
Firefox OS, Tizen
 Инсталация към съществуващ Cordova проект:
cordova plugin add org.apache.cordova.device-motion
 Документация:
http://plugins.cordova.io/#/package/org.apache.cordova.device-motion
@leonanavi
Акселерометър (демо)
function onSuccess(acceleration) {
alert('Acceleration X: ' + acceleration.x + 'n' +
'Acceleration Y: ' + acceleration.y + 'n' +
'Acceleration Z: ' + acceleration.z + 'n' +
'Timestamp: ' + acceleration.timestamp + 'n');
};
function onError() {
alert('onError!');
};
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
@leonanavi
Упражнение
 Да се напише Android програма чрез Cordova и плъгин
org.apache.cordova.device-motion, която засича
отместването на устройството по вертикала и в
зависимост от него определя посоката на движение по
хоризонтала на проста анимация в HTML5 canvas.
@leonanavi
Камера
 Cordova плъгин за правене на снимки или
избирането на снимки от галерията на устройствата
 Работи за Android, iOS, BlackBerry 10, Windows Phone,
Firefox OS, Tizen
 Инсталация към съществуващ Cordova проект:
cordova plugin add org.apache.cordova.camera
 Документация:
http://plugins.cordova.io/#/package/org.apache.cordova.ca
mera
@leonanavi
Снимка (демо)
function photo() {
cameraOptions = { quality : 100,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
saveToPhotoAlbum: true };
navigator.camera.getPicture(function(imageURI) {
var imgPhoto = document.getElementById('photo');
imgPhoto.style.visibility = 'visible';
imgPhoto.src = imageURI;
}, function(err) {
alert('Unable to take a photo.');
}, cameraOptions);
}
@leonanavi
KEEP CALM
AND
SUPPORT
FOSS

More Related Content

Viewers also liked

Комуникация между Internet Of Things чрез MQTT
Комуникация между Internet Of Things чрез MQTTКомуникация между Internet Of Things чрез MQTT
Комуникация между Internet Of Things чрез MQTT
Leon Anavi
 
Create IoT with Open Source Hardware, Tizen and HTML5
Create IoT with Open Source Hardware, Tizen and HTML5Create IoT with Open Source Hardware, Tizen and HTML5
Create IoT with Open Source Hardware, Tizen and HTML5
Leon Anavi
 
Направи си сам Raspberry Pi HAT
Направи си сам Raspberry Pi HATНаправи си сам Raspberry Pi HAT
Направи си сам Raspberry Pi HAT
Leon Anavi
 
The Yocto Project
The Yocto ProjectThe Yocto Project
The Yocto Project
Leon Anavi
 
Developing HTML5 applications for Tizen
Developing HTML5 applications for TizenDeveloping HTML5 applications for Tizen
Developing HTML5 applications for Tizen
Leon Anavi
 
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Leon Anavi
 
Connecting Internet of Things to the Cloud with MQTT
Connecting Internet of Things to the Cloud with MQTTConnecting Internet of Things to the Cloud with MQTT
Connecting Internet of Things to the Cloud with MQTT
Leon Anavi
 
Creating new Tizen profiles using the Yocto Project
Creating new Tizen profiles  using the Yocto ProjectCreating new Tizen profiles  using the Yocto Project
Creating new Tizen profiles using the Yocto Project
Leon Anavi
 

Viewers also liked (8)

Комуникация между Internet Of Things чрез MQTT
Комуникация между Internet Of Things чрез MQTTКомуникация между Internet Of Things чрез MQTT
Комуникация между Internet Of Things чрез MQTT
 
Create IoT with Open Source Hardware, Tizen and HTML5
Create IoT with Open Source Hardware, Tizen and HTML5Create IoT with Open Source Hardware, Tizen and HTML5
Create IoT with Open Source Hardware, Tizen and HTML5
 
Направи си сам Raspberry Pi HAT
Направи си сам Raspberry Pi HATНаправи си сам Raspberry Pi HAT
Направи си сам Raspberry Pi HAT
 
The Yocto Project
The Yocto ProjectThe Yocto Project
The Yocto Project
 
Developing HTML5 applications for Tizen
Developing HTML5 applications for TizenDeveloping HTML5 applications for Tizen
Developing HTML5 applications for Tizen
 
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
 
Connecting Internet of Things to the Cloud with MQTT
Connecting Internet of Things to the Cloud with MQTTConnecting Internet of Things to the Cloud with MQTT
Connecting Internet of Things to the Cloud with MQTT
 
Creating new Tizen profiles using the Yocto Project
Creating new Tizen profiles  using the Yocto ProjectCreating new Tizen profiles  using the Yocto Project
Creating new Tizen profiles using the Yocto Project
 

More from Leon Anavi

Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
Leon Anavi
 
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
Leon Anavi
 
Integrating VNC in Weston with the Yocto Project and OpenEmbedded
Integrating VNC in Weston with the Yocto Project and OpenEmbeddedIntegrating VNC in Weston with the Yocto Project and OpenEmbedded
Integrating VNC in Weston with the Yocto Project and OpenEmbedded
Leon Anavi
 
Как да убием и последната дискета с Open Source технологии?
Как да убием и последната дискета с Open Source технологии?Как да убием и последната дискета с Open Source технологии?
Как да убием и последната дискета с Open Source технологии?
Leon Anavi
 
Linux обновления с RAUC и Docker
Linux обновления с RAUC и DockerLinux обновления с RAUC и Docker
Linux обновления с RAUC и Docker
Leon Anavi
 
How to Choose a Software Update Mechanism for Embedded Linux Devices
How to Choose a Software Update Mechanism for Embedded Linux DevicesHow to Choose a Software Update Mechanism for Embedded Linux Devices
How to Choose a Software Update Mechanism for Embedded Linux Devices
Leon Anavi
 
Open Hardware Makers
Open Hardware MakersOpen Hardware Makers
Open Hardware Makers
Leon Anavi
 
Open Source Tools for Making Open Source Hardware
Open Source Tools for Making Open Source HardwareOpen Source Tools for Making Open Source Hardware
Open Source Tools for Making Open Source Hardware
Leon Anavi
 
A/B Linux updates with RAUC and meta-rauc-community: now & in the future
A/B Linux updates with RAUC and meta-rauc-community: now & in the futureA/B Linux updates with RAUC and meta-rauc-community: now & in the future
A/B Linux updates with RAUC and meta-rauc-community: now & in the future
Leon Anavi
 
Surfing on an Interactive Kiosk
Surfing on an Interactive KioskSurfing on an Interactive Kiosk
Surfing on an Interactive Kiosk
Leon Anavi
 
Linux дистрибуции и софтуерни обновления за вградени устройства
Linux дистрибуции и софтуерни обновления за вградени устройства Linux дистрибуции и софтуерни обновления за вградени устройства
Linux дистрибуции и софтуерни обновления за вградени устройства
Leon Anavi
 
Getting started with AGL using a Raspberry Pi
Getting started with AGL using a Raspberry PiGetting started with AGL using a Raspberry Pi
Getting started with AGL using a Raspberry Pi
Leon Anavi
 
Automotive Grade Linux on Raspberry Pi: How Does It Work?
Automotive Grade Linux on Raspberry Pi: How Does It Work?Automotive Grade Linux on Raspberry Pi: How Does It Work?
Automotive Grade Linux on Raspberry Pi: How Does It Work?
Leon Anavi
 
Comparison of Open Source Software Home Automation Tools
Comparison of Open Source Software Home Automation ToolsComparison of Open Source Software Home Automation Tools
Comparison of Open Source Software Home Automation Tools
Leon Anavi
 
Практични примери за device tree overlays на Raspberry Pi
Практични примери за device tree overlays на Raspberry PiПрактични примери за device tree overlays на Raspberry Pi
Практични примери за device tree overlays на Raspberry Pi
Leon Anavi
 
The Software Developer’s Guide to Open Source Hardware
The Software Developer’s Guide to Open Source HardwareThe Software Developer’s Guide to Open Source Hardware
The Software Developer’s Guide to Open Source Hardware
Leon Anavi
 
Making Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry PiMaking Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry Pi
Leon Anavi
 
Вграждане на умни гласови асистенти в устройства с Linux
Вграждане на умни гласови асистенти в устройства с LinuxВграждане на умни гласови асистенти в устройства с Linux
Вграждане на умни гласови асистенти в устройства с Linux
Leon Anavi
 
Comparison of Voice Assistant SDKs for Embedded Linux Devices
 Comparison of Voice Assistant SDKs for Embedded Linux Devices Comparison of Voice Assistant SDKs for Embedded Linux Devices
Comparison of Voice Assistant SDKs for Embedded Linux Devices
Leon Anavi
 
Open Source MQTT Brokers
Open Source MQTT BrokersOpen Source MQTT Brokers
Open Source MQTT Brokers
Leon Anavi
 

More from Leon Anavi (20)

Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
Screen Sharing on Raspberry Pi 5 Using VNC in Weston and Wayland with the Yoc...
 
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
Как да играем компютърни игри с Nintendo Wii Nunchuk чрез Raspberry Pi RP2040...
 
Integrating VNC in Weston with the Yocto Project and OpenEmbedded
Integrating VNC in Weston with the Yocto Project and OpenEmbeddedIntegrating VNC in Weston with the Yocto Project and OpenEmbedded
Integrating VNC in Weston with the Yocto Project and OpenEmbedded
 
Как да убием и последната дискета с Open Source технологии?
Как да убием и последната дискета с Open Source технологии?Как да убием и последната дискета с Open Source технологии?
Как да убием и последната дискета с Open Source технологии?
 
Linux обновления с RAUC и Docker
Linux обновления с RAUC и DockerLinux обновления с RAUC и Docker
Linux обновления с RAUC и Docker
 
How to Choose a Software Update Mechanism for Embedded Linux Devices
How to Choose a Software Update Mechanism for Embedded Linux DevicesHow to Choose a Software Update Mechanism for Embedded Linux Devices
How to Choose a Software Update Mechanism for Embedded Linux Devices
 
Open Hardware Makers
Open Hardware MakersOpen Hardware Makers
Open Hardware Makers
 
Open Source Tools for Making Open Source Hardware
Open Source Tools for Making Open Source HardwareOpen Source Tools for Making Open Source Hardware
Open Source Tools for Making Open Source Hardware
 
A/B Linux updates with RAUC and meta-rauc-community: now & in the future
A/B Linux updates with RAUC and meta-rauc-community: now & in the futureA/B Linux updates with RAUC and meta-rauc-community: now & in the future
A/B Linux updates with RAUC and meta-rauc-community: now & in the future
 
Surfing on an Interactive Kiosk
Surfing on an Interactive KioskSurfing on an Interactive Kiosk
Surfing on an Interactive Kiosk
 
Linux дистрибуции и софтуерни обновления за вградени устройства
Linux дистрибуции и софтуерни обновления за вградени устройства Linux дистрибуции и софтуерни обновления за вградени устройства
Linux дистрибуции и софтуерни обновления за вградени устройства
 
Getting started with AGL using a Raspberry Pi
Getting started with AGL using a Raspberry PiGetting started with AGL using a Raspberry Pi
Getting started with AGL using a Raspberry Pi
 
Automotive Grade Linux on Raspberry Pi: How Does It Work?
Automotive Grade Linux on Raspberry Pi: How Does It Work?Automotive Grade Linux on Raspberry Pi: How Does It Work?
Automotive Grade Linux on Raspberry Pi: How Does It Work?
 
Comparison of Open Source Software Home Automation Tools
Comparison of Open Source Software Home Automation ToolsComparison of Open Source Software Home Automation Tools
Comparison of Open Source Software Home Automation Tools
 
Практични примери за device tree overlays на Raspberry Pi
Практични примери за device tree overlays на Raspberry PiПрактични примери за device tree overlays на Raspberry Pi
Практични примери за device tree overlays на Raspberry Pi
 
The Software Developer’s Guide to Open Source Hardware
The Software Developer’s Guide to Open Source HardwareThe Software Developer’s Guide to Open Source Hardware
The Software Developer’s Guide to Open Source Hardware
 
Making Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry PiMaking Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry Pi
 
Вграждане на умни гласови асистенти в устройства с Linux
Вграждане на умни гласови асистенти в устройства с LinuxВграждане на умни гласови асистенти в устройства с Linux
Вграждане на умни гласови асистенти в устройства с Linux
 
Comparison of Voice Assistant SDKs for Embedded Linux Devices
 Comparison of Voice Assistant SDKs for Embedded Linux Devices Comparison of Voice Assistant SDKs for Embedded Linux Devices
Comparison of Voice Assistant SDKs for Embedded Linux Devices
 
Open Source MQTT Brokers
Open Source MQTT BrokersOpen Source MQTT Brokers
Open Source MQTT Brokers
 

HTML5 приложения за Android, урок 7

  • 1. HTML5 приложения за Android Урок 07 Леон Анави @leonanavi leon@anavi.org С подкрепата на:
  • 2. @leonanavi Съдържание  Cordova plugin за геолокация  Cordova plugin за ускорение  Cordova plugin за камера и работа със снимки
  • 3. @leonanavi Cordova Plugins  Допълнителни модули, които могат да се инсталират към Cordova приложение, за да се достъпи специфична за мобилните устройства функционалност през JavaScript.  Регистър за Cordova plugins: http://plugins.cordova.io/
  • 4. @leonanavi Геолокация  Cordova плъгин за работа с определяне на местоположението  Базиран на HTML5 Geolocation API: http://dev.w3.org/geo/api/spec-source.html  Работи за Android, iOS, BlackBerry 10, Windows Phone, Firefox OS  Инсталация към съществуващ Cordova проект: cordova plugin add org.apache.cordova.geolocation  Документация: http://plugins.cordova.io/#/package/org.apache.cordova.geolocation
  • 5. @leonanavi Акселерометър  Cordova плъгин за измерване на ускорението  Работи за Android, iOS, BlackBerry 10, Windows Phone, Firefox OS, Tizen  Инсталация към съществуващ Cordova проект: cordova plugin add org.apache.cordova.device-motion  Документация: http://plugins.cordova.io/#/package/org.apache.cordova.device-motion
  • 6. @leonanavi Акселерометър (демо) function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + 'n' + 'Acceleration Y: ' + acceleration.y + 'n' + 'Acceleration Z: ' + acceleration.z + 'n' + 'Timestamp: ' + acceleration.timestamp + 'n'); }; function onError() { alert('onError!'); }; navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
  • 7. @leonanavi Упражнение  Да се напише Android програма чрез Cordova и плъгин org.apache.cordova.device-motion, която засича отместването на устройството по вертикала и в зависимост от него определя посоката на движение по хоризонтала на проста анимация в HTML5 canvas.
  • 8. @leonanavi Камера  Cordova плъгин за правене на снимки или избирането на снимки от галерията на устройствата  Работи за Android, iOS, BlackBerry 10, Windows Phone, Firefox OS, Tizen  Инсталация към съществуващ Cordova проект: cordova plugin add org.apache.cordova.camera  Документация: http://plugins.cordova.io/#/package/org.apache.cordova.ca mera
  • 9. @leonanavi Снимка (демо) function photo() { cameraOptions = { quality : 100, destinationType : Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA, encodingType: Camera.EncodingType.JPEG, saveToPhotoAlbum: true }; navigator.camera.getPicture(function(imageURI) { var imgPhoto = document.getElementById('photo'); imgPhoto.style.visibility = 'visible'; imgPhoto.src = imageURI; }, function(err) { alert('Unable to take a photo.'); }, cameraOptions); }