Search in sources :

Example 1 with ApplicationInfo

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();
}
Also used : Bitmap(android.graphics.Bitmap) ApplicationInfo(android.content.pm.ApplicationInfo) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 2 with ApplicationInfo

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) {
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 3 with ApplicationInfo

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();
    }
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Bundle(android.os.Bundle) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 4 with ApplicationInfo

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;
}
Also used : PackageManager(android.content.pm.PackageManager) Bundle(android.os.Bundle) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 5 with ApplicationInfo

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);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) IOException(java.io.IOException) DexFile(dalvik.system.DexFile)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)1914 PackageManager (android.content.pm.PackageManager)682 Test (org.junit.Test)366 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)363 ArrayList (java.util.ArrayList)258 Intent (android.content.Intent)231 RemoteException (android.os.RemoteException)229 PackageInfo (android.content.pm.PackageInfo)214 ResolveInfo (android.content.pm.ResolveInfo)177 IOException (java.io.IOException)122 ActivityInfo (android.content.pm.ActivityInfo)114 IPackageManager (android.content.pm.IPackageManager)109 UserHandle (android.os.UserHandle)108 Context (android.content.Context)103 Bundle (android.os.Bundle)103 File (java.io.File)100 Drawable (android.graphics.drawable.Drawable)91 UserInfo (android.content.pm.UserInfo)89 ComponentName (android.content.ComponentName)69 SmallTest (android.support.test.filters.SmallTest)66