Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.*;
import android.content.pm.*;

public class Main {
    public static String getApplicationName(Context app) {
        PackageManager pm;
        ApplicationInfo ai;
        try {
            pm = app.getPackageManager();
            ai = pm.getApplicationInfo(app.getPackageName(), 0);
            return pm.getApplicationLabel(ai).toString();
        } catch (Exception e) {
            e.printStackTrace();
            return app.getPackageName();
        }
    }
}