EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

ProximityDevice.DeviceArrived | devicearrived event

Applies to Windows and Windows Phone

Occurs when a device enters the proximate range.

Syntax


function onDeviceArrived(eventArgs) { /* Your code */ }
 
// addEventListener syntax
proximityDevice.addEventListener("devicearrived", onDeviceArrived);
proximityDevice.removeEventListener("devicearrived", onDeviceArrived);
 
- or -

proximityDevice.ondevicearrived = onDeviceArrived;


Event information

Delegate DeviceArrivedEventHandler

Examples


function id(elementId) {
    return document.getElementById(elementId);
}

var proximityDevice;

function initializeProximityDevice() {
    proximityDevice = Windows.Networking.Proximity.ProximityDevice.getDefault();

    if (proximityDevice) {
        proximityDevice.addEventListener("devicearrived", proximityDeviceArrived);
        proximityDevice.addEventListener("devicedeparted", proximityDeviceDeparted);

        id("messageDiv").innerHTML += "Proximity device initialized.<br />";
    }
    else {
        id("messageDiv").innerHTML += "Failed to initialized proximity device.<br />";
    }
}

function proximityDeviceArrived(device) {
    id("messageDiv").innerHTML += "Proximate device arrived. id = " + device.deviceId + "<br />";
}

function proximityDeviceDeparted(device) {
    id("messageDiv").innerHTML += "Proximate device departed. id = " + device.deviceId + "<br />";
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Networking.Proximity
Windows::Networking::Proximity [C++]

Metadata

Windows.winmd

Capabilities

proximity
ID_CAP_PROXIMITY [Windows Phone]

See also

ProximityDevice
Proximity and Tapping (JavaScript)
Proximity and Tapping (C#/VB/C++)
Samples
Proximity sample

 

 

Mostrar:
© 2014 Microsoft