Start a new topic

How to Vibrate on button click

How to Vibrate on button click

I want to vibrate the phone on button click.

Thanks in Advance

There is no direct way of doing this from javascript. You need to signal back to the native app (using an url like architectsdk://) and react on that call (ArchitectUrlListener or delegate) by calling the standard platforms vibrate API.

I am not getting it.Please give me some idea.


Hi i have made a native vibrator method in my java file but not able to call that method in imagerecognitionand3d.js

If anyone has the solution please provide it.


Have you implemented the ArchitectUrlListener? It's urlWasInvoked method is called whenever you load a url that starts with the protocol "architectsdk://".

Please see the example 5 Browsing POIs - Native Detail Page for an implementation of how to communicate with native code from javascript.

So to summarize these steps need to be taken:

1. Implement ArchtiectUrlListener, use its urlWasInvoked method to execute java code. in your case the vibrate method 

2. Register the listener with the ArchitectView

3. In Javascript whenever you want to signal to the native java code, do the following:

document.location = "architectsdk://vibrate"

Make sure that the url starts with the architectsdk:// protocol

i tried using document.location = "architectsdk://vibrate" but its giving me alert that architectsdk://vibrate not supported


You need to register the ArchitectUrlListener with the ArchitectView, otherwise this error is displayed if such an url is encountered.

Kindly please help me.

how and where to register the ArchitectUrlListener with the ArchitectView.


If any one has the idea how and where to register the ArchitectUrlListener with the ArchitectView  please provide it.


check out the updated documentation of the PhoneGap Setup Guide - especially the chapter "Adding communication between PhoneGap and ARchitect" (close to the bottom) where it is described in detail where to add the callback.

I have written the vibrate function in my and trying to call that function in imagerecognitionand3d.js but not able to call that function in imagerecognitionand3d.js

Kindly help me.


I'm a bit confused now. Are you using phonegap? If so please see the PhoneGap Setup Guide as Philipp suggested above and read the section on communicating between PhoneGap and ARchitect.

Also make sure to use the latest phonegap plugin and Wikitude SDK. It shouldn't be necessary to change any .java file when using Phonegap.

If I'm wrong, please state what and how you have implemented the communication between js and native code.
Login or Signup to post a comment