Implementation of the list of used libraries in the Android application. Attempt number 2

More recently I came across an article on Habr on how to implement a dialog box with a list of used libraries. The proposed option seemed to me too complicated, and the list itself looked crooked. In this regard, I decided to share a simpler and more elegant way to implement this functionality.

We write the dependency in the build.gradle of our module:


Now we need to create a list with the libraries used. To do this, create a license.xml file in the res / raw folder (you can use other names).


Application Crash Reporting for Android (ACRA) 2010 Emmanuel Astier & Kevin GaudinApache Software License 2.0Android ViewPagerIndicator (C) 2011 The Android Open Source Project
Copyright (C) 2012 Jake Wharton
Apache Software License 2.0
OrmLite Gray WatsonISC LicensePhotoView 2011, 2012 Chris Banes.Apache Software License 2.0

As you can see, we don’t need to write a huge text of the license, but we can only indicate its name. Based on this file, the library will generate HTML code, which will then be displayed in the dialog box. At the time of writing, the following licenses are supported:

  • Apache Software License 2.0
  • BSD 2/3 Clause License
  • Gnu General Public License 2.0 / 3.0
  • GNU Lesser General Public License 2.1 / 3
  • MIT
  • Mozilla Public License 1.1

You can also create your own license by inheriting from the License class and implementing abstract methods.

If the library does not have copyright, then we simply write:

It remains to write the code in our Activity:

new LicensesDialog.Builder(this)

Here is the output:


You can also create a license directly in Java:

final String name = "LicensesDialog";
final String url = "";
final String copyright = "Copyright 2013 Philip Schiffer ";
final License license = new ApacheSoftwareLicense20();
final Notice notice = new Notice(name, url, copyright, license);
new LicensesDialog.Builder(this)

The source code of the example can be found here . Thanks for attention.

Also popular now: