Developers Club geek daily blog

2 years, 5 months ago
Often at implementation of mobile application for Android c use in it different third-party libraries requires to mention them in the project not to violate the right of 3 persons and not to get in Bang with your project in app store of Google Play.

We need to put the description of the used libraries in the appendix and to specify their license.
It is about libraries which are on GitHub.

The description of licenses is in a project tree in the file. According to this link, it is possible to look at the description of the license of Picasso library (it is necessary to thumb through in the bottom).

So, this requirement is implemented by means of DialogFragment, it is possible to implement it and by means of AlertDialog (it is better for Fragment to use as it saves the status at revolution of a device). It is recommended to place this feature either in Navigation Drawer, or in Overflow.

That it was clear what there is a speech about, here is how it looks at one very popular application:




It is necessary to create the assets folder in an app directory root (the right button it is clicked on app> new> folder> assets folder and we click finish of nothing without changing), where to place our .html the file with the description of libraries and licenses which we use.

With the right button it is clicked on assets> new> file> name.html

I called the file: open_source_licenses.html

Open_source_licenses.html file contents:

        body {
        font-family: sans-serif;
        pre {
        background-color: #eeeeee;
        padding: 1em;
        white-space: pre-wrap;

    Apache License
    Version 2.0, January 2004
        Copyright 2013 Square, Inc.
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.



We create the file in the layout folder in which we will just place only WebView and we will call it — dialog_license.xml:

<?xml version="1.0" encoding="utf-8"?>


We create new java a class and we call it, for example — and we place such code in this class:

public class LicensesDialogFragment extends DialogFragment {

    public static LicensesDialogFragment newInstance() {
        return new LicensesDialogFragment();

    public Dialog onCreateDialog(Bundle savedInstanceState) {
        WebView view = (WebView) LayoutInflater.from(getActivity()).inflate(R.layout.dialog_license, null);
        return new AlertDialog.Builder(getActivity(),
                .setPositiveButton(android.R.string.ok, null)


We place a line in which we will specify heading for our dialog in strings.xml:

<string name="action_licenses">Лицензии открытого ПО</string>


To or in yours of an aktivita where there is Navigation Drawer, we write the following method:

private void displayLicensesDialogFragment() {
        LicensesDialogFragment dialog = LicensesDialogFragment.newInstance();, "LicensesDialog");


Now, we call this method where we want. I put it on onNavigationItemSelected:


Do not forget to create the corresponding item in main.xml or activity_main_drawer.xml in dependence where you want to place your method.

Here that turned out at me:


P.S. Yes, a html-code it is possible and it is necessary to podmarafetit a little that it did not creep away, but it put already personally everyone, I wanted to show in this article how to work with licenses of libraries.
And you in the projects add the description of the used libraries?

29 people voted. 12 people refrained.

The users only registered can participate in poll. Enter, please.

This article is a translation of the original post at
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here:

We believe that the knowledge, which is available at the most popular Russian IT blog, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.
Best wishes.

comments powered by Disqus