Android documentation

Basics

Doorbell requires a min SDK version of 3.

You can install Doorbell via Maven Central.

Include the following in your dependencies:

compile 'io.doorbell:android-sdk:0.2.6@aar'

For the library to work, your app will need to have the Internet permission. To do this (if it doesn't already), just add the following line to your application's AndroidManifest.xml:

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

In the activity where you want to use Doorbell, you'll need to import the library using:

import io.doorbell.android.Doorbell;

Methods

The Doorbell object extends the AlertDialog.Builder class, so you can access all the existing methods (such as setTitle(String title)).

There are 5 methods that you can call on the Doorbell object: setEmail(String email), addProperty(String key, Object value), setEmailFieldVisibility(int visibility), setPoweredByVisibility(int visibility) and show():

Example


    // In your activity
    int appId = 0; // Replace with your application's ID
    String apiKey = "YOUR-API-KEY-GOES-HERE"; // Replace with your application's API key
    Doorbell doorbellDialog = new Doorbell(this, appId, apiKey); // Create the Doorbell object

    doorbellDialog.setEmail("name@example.com"); // Prepopulate the email address field
    doorbellDialog.setName("Philip Manavopoulos"); // Set the name of the user (if known)
    doorbellDialog.addProperty("loggedIn", true); // Optionally add some properties
    doorbellDialog.addProperty("username", 'manavo');
    doorbellDialog.addProperty("loginCount", 123);
    doorbellDialog.setEmailFieldVisibility(View.GONE); // Hide the email field, since we've filled it in already
    doorbellDialog.setPoweredByVisibility(View.GONE); // Hide the "Powered by Doorbell.io" text

    // Callback for when a message is successfully sent
    doorbellDialog.setOnFeedbackSentCallback(new io.doorbell.android.callbacks.OnFeedbackSentCallback() {
        @Override
        public void handle(String message) {
            // Show the message in a different way, or use your own message!
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        }
    });

    // Callback for when the dialog is shown
    doorbellDialog.setOnShowCallback(new io.doorbell.android.callbacks.OnShowCallback() {
        @Override
        public void handle() {
            Toast.makeText(context, "Dialog shown", Toast.LENGTH_LONG).show();
        }
    });

    doorbellDialog.show();
            

Localization

You can change all the strings in the dialog by using the following methods:

setTitle, setEmailHint, setMessageHint, setPositiveButtonText, and setNegativeButtonText.

They all work with either a string, or a resource string ID.

Example


    // In your activity
    int appId = 0; // Replace with your application's ID
    String apiKey = "YOUR-API-KEY-GOES-HERE"; // Replace with your application's API key
    Doorbell doorbellDialog = new Doorbell(this, appId, apiKey); // Create the Doorbell object

    doorbellDialog.setTitle(R.string.doorbell_title);
    doorbellDialog.setEmailHint("Your address");
    doorbellDialog.setMessageHint("What would you like to tell us?");
    doorbellDialog.setPositiveButtonText("Send");
    doorbellDialog.setNegativeButtonText(android.R.string.cancel);

    doorbellDialog.show();