Main white everlink logo
text_snippet Examples
Coming soon
text_snippet Examples
Coming soon

Create ultra-contactless token communication

(!) BEFORE GETTING STARTED

flash_on You should have a token based Android app.

Guide focus: Setting up Everlink’s Android SDK to enable sonic-key to token exchange.

There are two core elements to consider in this process, Set Up and Usage.

Set Up: Please follow the steps below to get started:

  1. Add Everlink SDK to your app in Android Studio
  2. Add the required permissions
  3. Calling the EverlinkConnect class

1) Add EverLink SDK to your app

Step 1 requires account approval

2) Permissions

Next you need to add the required permissions to the AndroidManifest.xml file:

       <Manifest>

       <uses-permission android:name="android.permission.RECORD_AUDIO" />
       
       <uses-permission android:name="android.permission.INTERNET" />

       <Application>
       // Other codes...
       </Application>       
       </Manifest>

      

3) Call the EverlinkConnect class

In order to start using Everlink - so that you can receive and send tokens over audio - you have to call the EverLinkConnect class, and set its listeners.

Changing the package at the top to the correct package of your project, and string myAppID to your key, which you can find in the account page, and importing the EverLinkConnect class from the SDK:


      package com.everlinkdemo;

      // Other codes...

      import com.everlink.broadcast.util.EverLinkConnect;

      // Other codes...


      public class MainActivity extends AppCompatActivity {

          protected static final int REQUEST_MICROPHONE = 8000;
          private com.everlink.broadcast.util.EverLinkConnect EverLinkConnect;

          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);

          String myAppID = "12345";
              
          //check permissions
          if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.RECORD_AUDIO)
          != PackageManager.PERMISSION_GRANTED ) {
          ActivityCompat.requestPermissions( this, new String[] {
          android.Manifest.permission.RECORD_AUDIO  }, REQUEST_MICROPHONE); }
              
          EverLinkConnect = new EverLinkConnect(getApplicationContext(), this, myAppID);
          EverLinkConnect.setAudioListener(new EverLinkConnect.audioListener() {
          
          @Override
          public void onAudioCodeReceived(String token) {
          // you can now identify, via the server returned token, what location/device was heard
          Log.d("newToken",token);
          }
          @Override
          public void onEverLinkError(String error) {
          //return the type of error received: server response, no internet, no permissions
          }
          @Override
          public void onMyTokenGenerated(String token){
          //a new token generated, to save in your database
          Log.d("newToken",token);
          }
          });
              
          }

      }

      

CONGRATS you’ve now set-up Everlink! Now onto usage.


Usage: After the client app is set up, you are ready to begin verifying and identifying devices, you can now:

  1. Detect codes
  2. Send codes
The EverLinkConnect class has a number of listeners and methods that you can use to send and receive audio codes. We do all audio code generation, token checks and returns, and stop listening on code detection automatically.

1) Detect Code

When you want to detect an audio code simply call: EverLinkConnect.startListening();


      // Other codes...
      listenButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
         //to start listening for a code call:

         EverLinkConnect.startListening();
                    
         }
      });
      // Other codes...
      stopListenButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
         //to stop listening call:

         EverLinkConnect.stopListening();
                    
         }
      });
      // Other codes...

      
Which will cause the device to start listening for an audio code, on successful detection we will return the identifying token of the heard device via the onAudioCodeReceived listener.

2) Send Code

When you want to start emitting an audio code simply call: EverLinkConnect.startEmitting();


      // Other codes...
      playButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
         //to start emitting an audio code call:

         EverLinkConnect.startEmitting();
                    
         }
      });
      // Other codes...
      stopButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
         ////to stop emitting call:

         EverLinkConnect.stopEmitting();
                    
         }
      });
      // Other codes...

      

You can alternatively pass a token as an argument and its audio code will play, as shown below:

      // Other codes...
      playToken.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        //to start emitting an audio code call:
                                         
        EverLinkConnect.startEmittingToken("exampleToken12345");
                                         
       }

      });
      // Other codes...

      

If you wish to manually generate a new user token call: EverLinkConnect.createNewToken();


      // Other codes...
      newTokenButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        //Generate a new user token to save in your database
                  
        EverLinkConnect.createNewToken();
                     
         }

      });
      // Other codes...

      
We generate new tokens automatically, and also swap the associated audio code often for security reasons so manual calls are not needed. We will return your identifying token via the onMyTokenGenerated listener.