[Android SDK] Using Lynx – An opensource Library from @pedrovgs

These are very quick steps to import Lynx into your Android project. For further information, visit the official GitHub site.

1.- Include gradle dependency for Lynx inside your project. In this moment it is this one:

compile 'com.github.pedrovgs:lynx:1.5’

you may search at the GitHub site if there are new versions

2.1.- Declare LynxActivity inside your manifest, next to the rest of your Activities

<activity android:name="com.github.pedrovgs.lynx.LynxActivity”/>

2.2.- Add READ_LOGS permission

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

3.- Then, you have three options to start using Lynx:

3a.- Open LynxActivity in code

private void openLynxActivity() {
    LynxConfig lynxConfig = new LynxConfig();
    lynxConfig.setMaxNumberOfTracesToShow(4000).setFilter("MyAppName");

        Intent lynxActivityIntent = LynxActivity.getIntent(this, lynxConfig);
    startActivity(lynxActivityIntent);
}

3b.- Add LynxView to your layout

<com.github.pedrovgs.lynx.LynxView
      xmlns:lynx="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      lynx:filter="MyAppName"
      lynx:text_size="12sp"/>

3c.- Declare an application-wide LynxShakeDetector and initialize it

public void initializeLynxShakeDetector(){
   LynxShakeDetector lynxShakeDetector = new LynxShakeDetector(this);
   lynxShakeDetector.init();
}

thanks to @pedrovgs for this fantastic library!!! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s