/*
* Copyright (C) 2009 Show SMS open source project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package com.bydavy.util.showsms;
//~--- non-JDK imports --------------------------------------------------------
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import com.bydavy.android.showsms.SSPreferenceActivity;
/**
* Class description
*
*
* @version 1.0, 09/11/17
* @author Davy L.
*/
public class Infos {
//~--- static fields ------------------------------------------------------
/** To optimize query, queried one time */
static private String versionName = null;
//~--- get methods --------------------------------------------------------
/**
* Method to retrieve the version name of Show SMS
*
* @param context application context
*
* @return Application Version Name defined in the AndroidManifest.xml
*/
public static String getVersionName(Context context) {
if (versionName == null) {
PackageManager pm = context.getPackageManager();
try {
PackageInfo pi = pm.getPackageInfo(SSPreferenceActivity.class.getPackage().getName(), 0);
versionName = pi.versionName;
} catch (NameNotFoundException e) {
AppLog.e("AboutDialog: getVersionName() ERROR");
}
}
return versionName;
}
}
|