DOCUMENTATION

Android Applications

See the basic setup steps below to get started with the Logify Alert service:

Generate an API Key

The Logify Alert service uses unique identifiers – API keys – to register and monitor individual applications. You will use this key later when creating an instance of Logify Alert client in code.

  1. Log in to the Logify Alert website: logify.devexpress.com.

  2. Switch to the Applications tab and click Create New Application.

  3. Specify the application name and description, then click Create.

  4. The Applications tab will now display a new entry with an auto-generated API key.

Send Reports to Logify Alert

This section explains how to make your Android application send unhandled exceptions to the Logify Alert service.

Add the Logify Alert Client to Your Project

In your application module's build.gradle file, do the following:

  1. In the dependencies section, declare the logify-alert-android library dependency:

    compile "com.devexpress.logify:logify-alert-android:1.0.2"

  2. In the repositories section, declare the Logify Alert's maven repository:

    maven {
        url "https://github.com/DevExpress/Logify.Alert.Clients/raw/maven"
    }
    

  3. In the defaultConfig section, ensure that minSdkVersion is set to a value from 17 to 28.

In the pom.xml file, do the following:

  1. In the dependencies section, declare the logify-alert-android library dependency:

    <dependency>
      <groupId>com.devexpress.logify</groupId>
      <artifactId>logify-alert-android</artifactId>
      <version>1.0.2</version>
    </dependency>

  2. In the repositories section, declare the Logify Alert's maven repository:

    <repository>
      <id>any-name-or-id</id>
      <url>https://github.com/DevExpress/Logify.Alert.Clients/raw/maven </url>
    </repository>
    

  3. In the defaultConfig section, ensure that minSdkVersion is set to a value from 17 to 28.

Synchronize your project.

Send Reports Automatically

Initialize and configure the Logify Alert client in the onCreate method of your application's main activity to automatically intercept all unhandled exceptions and send the corresponding crash reports to Logify Alert:

import com.devexpress.logify.alert.android.LogifyAlert;

 public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Initialize the Logify Alert client.
        LogifyAlert client = LogifyAlert.getInstance();
        
        // Specify an API Key to register your application in the Logify Alert service.        
        client.setApiKey("YOUR_API_KEY");

        // Optional but recommended. 
        // Pass your application context to the Logify Alert client   
        // to include application environment information in crash reports.
        client.setContext(this.getApplicationContext());

        // Report unhandled exceptions to Logify Alert.
        client.startExceptionsHandling();
    }
}

Alternatively, you can specify an API Key in the logify.properties file (Logify Alert reads this file if you pass your application context to the client using the setContext method):

apiKey=YOUR_API_KEY

Send Reports Manually

Use the following code to catch exceptions and send reports manually.

import com.devexpress.logify.alert.android.LogifyAlert;

try {
    // Some code
}
catch (Throwable ex){
    LogifyAlert client = LogifyAlert.getInstance();
    client.setApiKey("YOUR_API_KEY");
    client.send(e);
}

Rebuild and Run Your Application

Once your updated application has been redeployed, log in to logify.devexpress.com to review and process incoming reports.

Terms of use Copyright © 2016-2019 Developer Express Inc.