try {
if (Utils.isDebugBuild(getApplicationContext())) {
map = new MapView(this, getString(R.string.maps_debug_key));
} else {
map = new MapView(this, getString(R.string.maps_release_key));
}
AbsListView.LayoutParams params = new AbsListView.LayoutParams(
AbsListView.LayoutParams.FILL_PARENT,
AbsListView.LayoutParams.FILL_PARENT);
map.setEnabled(true);
map.setClickable(true);
FrameLayout topLevelView = (FrameLayout)findViewById(R.id.home_container);
topLevelView.addView(map, 0, params );
} catch (PackageManager.NameNotFoundException e) {
Log.e("busmapper", "Couldn't find package name", e);
CustomToast.makeToastAndShow(this, "Serious Error - no package name");
}
... And our Utils class:
public static boolean isDebugBuild(Context c) throws PackageManager.NameNotFoundException {
PackageManager pm = c.getPackageManager();
PackageInfo pi = pm.getPackageInfo(c.getPackageName(), 0);
return ((pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
}
No comments:
Post a Comment