-
Notifications
You must be signed in to change notification settings - Fork 982
/
ManifestUtil.java
42 lines (35 loc) · 1.31 KB
/
ManifestUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.osmdroid.tileprovider.util;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import org.osmdroid.api.IMapView;
/**
* Utility class for reading the manifest
*/
public class ManifestUtil {
/**
* Retrieve a key from the manifest meta data, or empty string if not found.
*/
public static String retrieveKey(final Context aContext, final String aKey) {
// get the key from the manifest
final PackageManager pm = aContext.getPackageManager();
try {
final ApplicationInfo info = pm.getApplicationInfo(aContext.getPackageName(),
PackageManager.GET_META_DATA);
if (info.metaData == null) {
Log.i(IMapView.LOGTAG, "Key %s not found in manifest" + aKey);
} else {
final String value = info.metaData.getString(aKey);
if (value == null) {
Log.i(IMapView.LOGTAG, "Key %s not found in manifest" + aKey);
} else {
return value.trim();
}
}
} catch (final PackageManager.NameNotFoundException e) {
Log.i(IMapView.LOGTAG, "Key %s not found in manifest" + aKey);
}
return "";
}
}