use of android.content.pm.ApplicationInfo in project buck by facebook.
the class ExoMetaLogActivity method onCreate.
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
ApplicationInfo appInfo = getPackageManager().getApplicationInfo("buck.exotest", PackageManager.GET_META_DATA);
Bitmap icon = getIcon(appInfo);
Bitmap defaultIcon = ((BitmapDrawable) getPackageManager().getApplicationIcon(getApplicationInfo())).getBitmap();
if (icon == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no icon");
} else if (icon.sameAs(defaultIcon)) {
Log.i("EXOPACKAGE_TEST_META", "Found default icon");
} else {
Log.i("EXOPACKAGE_TEST_META", "META_ICON=" + icon.getWidth() + "_" + icon.getHeight());
}
String name = getName(appInfo);
if (name == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no name");
} else {
Log.i("EXOPACKAGE_TEST_META", "META_NAME=" + name);
}
String[] meta = getMeta(appInfo);
if (meta == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no metadata");
} else {
String metaStr = "<";
for (int i = 0; i < meta.length; i++) {
metaStr += (i == 0 ? "" : ",") + meta[i];
}
metaStr += ">";
Log.i("EXOPACKAGE_TEST_META", "META_DATA=" + metaStr);
}
} catch (Exception e) {
Log.i("EXOPACKAGE_TEST_META_DEBUG", "Got an exception", e);
}
Log.i("EXOPACKAGE_TEST_META", "FINISHED");
finish();
}
use of android.content.pm.ApplicationInfo in project packer-ng-plugin by mcxiaoke.
the class MainActivity method addAppInfoSection.
private void addAppInfoSection() {
try {
final ApplicationInfo info = getApplicationInfo();
StringBuilder builder = new StringBuilder();
builder.append("[AppInfo]\n");
builder.append("SourceDir: ").append(getSourceDir(this)).append("\n");
builder.append("Market: ").append(PackerNg.getMarket(this)).append("\n");
builder.append("MarketInfo: ").append(PackerNg.getMarketInfo(this)).append("\n");
builder.append("Name: ").append(getString(info.labelRes)).append("\n");
builder.append("Package: ").append(BuildConfig.APPLICATION_ID).append("\n");
builder.append("VersionCode: ").append(BuildConfig.VERSION_CODE).append("\n");
builder.append("VersionName: ").append(BuildConfig.VERSION_NAME).append("\n");
builder.append("ProcessName: ").append(info.processName).append("\n");
builder.append("CodePath: ").append(getPackageCodePath()).append("\n");
builder.append("SourceDir: ").append(info.sourceDir).append("\n");
builder.append("PubSourceDir: ").append(info.publicSourceDir).append("\n");
builder.append("DataDir: ").append(info.dataDir).append("\n");
builder.append("Signature:\n");
builder.append(AndroidUtils.getSignature(this)).append("\n");
builder.append("\n");
addSection(builder.toString());
} catch (Exception e) {
}
}
use of android.content.pm.ApplicationInfo in project packer-ng-plugin by mcxiaoke.
the class MainActivity method addMetaDataSection.
private void addMetaDataSection() {
final PackageManager pm = getPackageManager();
final String packageName = getPackageName();
try {
final ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_SIGNATURES | PackageManager.GET_META_DATA);
final Bundle bundle = info.metaData;
final StringBuilder builder = new StringBuilder();
builder.append("[MetaData]\n");
if (bundle != null) {
final Set<String> keySet = bundle.keySet();
for (final String key : keySet) {
builder.append(key).append("=").append(bundle.get(key)).append("\n");
}
}
addSection(builder.toString());
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
use of android.content.pm.ApplicationInfo in project nmid-headline by miao1007.
the class JPushUtils method getAppKey.
// 取得AppKey
public static String getAppKey(Context context) {
Bundle metaData = null;
String appKey = null;
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
if (null != ai)
metaData = ai.metaData;
if (null != metaData) {
appKey = metaData.getString(KEY_APP_KEY);
if ((null == appKey) || appKey.length() != 24) {
appKey = null;
}
}
} catch (PackageManager.NameNotFoundException e) {
}
return appKey;
}
use of android.content.pm.ApplicationInfo in project jmonkeyengine by jMonkeyEngine.
the class MainActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
Log.d(TAG, "Restoring selections in onCreate: " + "position: " + savedInstanceState.getInt(SELECTED_LIST_POSITION, 0) + "class: " + savedInstanceState.getString(SELECTED_APP_CLASS));
currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true);
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
enableKeyEvents = savedInstanceState.getBoolean(ENABLE_KEY_EVENTS, true);
verboseLogging = savedInstanceState.getBoolean(VERBOSE_LOGGING, true);
}
/* Set content view and register views */
setContentView(R.layout.test_chooser_layout);
btnOK = (Button) findViewById(R.id.btnOK);
btnCancel = (Button) findViewById(R.id.btnCancel);
listClasses = (ListView) findViewById(R.id.listClasses);
editFilterText = (EditText) findViewById(R.id.txtFilter);
/* Define the root package to start with */
rootPackage = "jme3test";
/* Create an array of Strings to define which classes to exclude */
// inner classes
exclusions.add("$");
// Desktop test chooser class
exclusions.add("TestChooser");
// Desktop test chooser class
exclusions.add("awt");
// mExclusions.add("");
/*
* Read the class names from the dex file and filter based on
* name and super class.
*/
Log.d(TAG, "Composing Test list...");
ApplicationInfo ai = this.getApplicationInfo();
String classPath = ai.sourceDir;
DexFile dex = null;
Enumeration<String> apkClassNames = null;
try {
dex = new DexFile(classPath);
apkClassNames = dex.entries();
while (apkClassNames.hasMoreElements()) {
String className = apkClassNames.nextElement();
if (checkClassName(className) && checkClassType(className)) {
classNames.add(className);
}
// classNames.add(className);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
dex.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* Create a backing Adapter for the List View from a list of the
* classes. The list is defined by array of class names.
*/
arrayAdapter = new CustomArrayAdapter(this, // text view to display selection
R.layout.test_chooser_row, // array of strings to display
classNames);
/* Set the resource id for selected and non selected backgrounds */
Log.d(TAG, "Setting Adapter Background Resource IDs");
arrayAdapter.setSelectedBackgroundResource(R.drawable.selected);
arrayAdapter.setNonSelectedBackgroundResource(R.drawable.nonselected);
/* Attach the Adapter to the spinner */
Log.d(TAG, "Setting ListView Adapter");
listClasses.setAdapter(arrayAdapter);
/* Set initial selection for the list */
setSelection(currentPosition);
/* Set Click and Text Changed listeners */
listClasses.setOnItemClickListener(this);
btnOK.setOnClickListener(this);
btnCancel.setOnClickListener(this);
editFilterText.addTextChangedListener(this);
}
Aggregations