Android ApplicationInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ApplicationInfo class.

This code example shows how to use the following methods:
This code example shows how to use the following methods:loadLabel
        mContext = context;
    } 
 
    public String GetApplicationName(ApplicationInfo info)
    { 
        return (String) info.loadLabel(mContext.getPackageManager());
    } 
 
    public boolean InstallAppFromMarket(String AppID)
    { 
        boolean result = true;
        try 
        { 
            Intent intent = new Intent(
                Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + AppID)
                ); 
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
        } 
7
CodeRank
This code example shows how to use the following methods:
 
  @Test 
  public void getApplicationInfo__OtherApplication() throws Exception { 
    PackageInfo packageInfo = new PackageInfo();
    packageInfo.packageName = TEST_PACKAGE_NAME;
    packageInfo.applicationInfo = new ApplicationInfo();
    packageInfo.applicationInfo.packageName = TEST_PACKAGE_NAME;
    packageInfo.applicationInfo.name = TEST_PACKAGE_LABEL;
    rpm.addPackage(packageInfo);
 
    ApplicationInfo info = rpm.getApplicationInfo(TEST_PACKAGE_NAME, 0);
    assertThat(info).isNotNull();
    assertThat(info.packageName).isEqualTo(TEST_PACKAGE_NAME);
    assertThat(rpm.getApplicationLabel(info).toString()).isEqualTo(TEST_PACKAGE_LABEL);
  } 
 
  @Test(expected = PackageManager.NameNotFoundException.class) 
  public void removePackage_shouldHideItFromGetApplicationInfo() throws Exception { 
    PackageInfo packageInfo = new PackageInfo();
    packageInfo.packageName = TEST_PACKAGE_NAME;
6
CodeRank
This code example shows how to use the following methods:
 
    @Test 
    public void getApplicationInfo__OtherApplication() throws Exception { 
        PackageInfo packageInfo = new PackageInfo();
        packageInfo.packageName = TEST_PACKAGE_NAME;
        packageInfo.applicationInfo = new ApplicationInfo();
        packageInfo.applicationInfo.packageName = TEST_PACKAGE_NAME;
        packageInfo.applicationInfo.name = TEST_PACKAGE_LABEL;
        rpm.addPackage(packageInfo);
 
        ApplicationInfo info = rpm.getApplicationInfo(TEST_PACKAGE_NAME, 0);
        assertThat(info).isNotNull();
        assertThat(info.packageName).isEqualTo(TEST_PACKAGE_NAME);
        assertThat(rpm.getApplicationLabel(info).toString()).isEqualTo(TEST_PACKAGE_LABEL);
    } 
 
    @Test(expected = PackageManager.NameNotFoundException.class) 
    public void removePackage_shouldHideItFromGetApplicationInfo() throws Exception { 
        PackageInfo packageInfo = new PackageInfo();
        packageInfo.packageName = TEST_PACKAGE_NAME;
6
CodeRank
This code example shows how to use the following methods:
        return realContextWrapper == getApplicationContext() ? packageName : getApplicationContext().getPackageName();
    } 
 
    @Implementation 
    public ApplicationInfo getApplicationInfo() {
        ApplicationInfo appInfo = new ApplicationInfo();
        appInfo.name = appName;
        appInfo.packageName = packageName;
        appInfo.processName = packageName;
        return appInfo;
    } 
 
    /** 
     * Non-Android accessor to set the application name. 
     * 
     * @param name 
     */ 
    public void setApplicationName(String name) {
        appName = name;
    } 
6
CodeRank
This code example shows how to use the following methods:
 
        @Override 
        public ApplicationInfo getApplicationInfo() {
            ApplicationInfo containingInfo = context.getApplicationInfo();
 
            ApplicationInfo info = new ApplicationInfo();
            info.sourceDir = getFile().getParent();
            info.packageName = packageName;
            info.uid = containingInfo.uid;
            //info.sharedLibraryFiles = containingInfo.sharedLibraryFiles; 
            //info.dataDir = containingInfo.dataDir; 
            info.targetSdkVersion = containingInfo.targetSdkVersion;
 
            info.className = android.app.Application.class.getName();;
            info.descriptionRes = 0;
            info.theme = 0; // populate later on from apk?
            info.manageSpaceActivityName = null;
            info.flags = 0;
            info.publicSourceDir = info.sourceDir;
            info.sharedLibraryFiles = null;

5
CodeRank
This code example shows how to use the following methods:
                return "no.package"; 
            } 
 
            @Override 
            public ApplicationInfo getApplicationInfo() {
                ApplicationInfo ai = new ApplicationInfo();
                ai.packageName = "contactsTestPackage";
                return ai;
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper =
                new RenamingDelegatingContext(context, targetContext, "perf.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();
        IsolatedContext providerContext = new IsolatedContext(resolver, targetContextWrapper);
        SynchronousContactsProvider2 provider = new SynchronousContactsProvider2();
        provider.setDataWipeEnabled(false);
        provider.attachInfo(providerContext, null);
        resolver.addProvider(ContactsContract.AUTHORITY, provider);
 
        long rawContactCount = provider.getRawContactCount();
6
CodeRank
This code example shows how to use the following methods:
    @Override 
    public ApplicationInfo getApplicationInfo(String packageName, int flags) throws NameNotFoundException {
 
        if (config.getPackageName().equals(packageName)) {
            if (applicationInfo == null) {
                applicationInfo = new ApplicationInfo();
                applicationInfo.flags = config.getApplicationFlags();
                applicationInfo.targetSdkVersion = config.getSdkVersion();
                applicationInfo.packageName = config.getPackageName();
                applicationInfo.processName = config.getProcessName();
            } 
            return applicationInfo;
        } 
         
        PackageInfo info;
        if ((info = packageList.get(packageName)) != null) {
        	return info.applicationInfo;
        } 
 
        throw new NameNotFoundException(); 
5
CodeRank
This code example shows how to use the following methods:loadLabel
This code example shows how to use the following methods:
        return realContextWrapper == getApplicationContext() ? packageName : getApplicationContext().getPackageName();
    } 
 
    @Implementation 
    public ApplicationInfo getApplicationInfo() {
        ApplicationInfo appInfo = new ApplicationInfo();
        appInfo.name = appName;
        appInfo.packageName = packageName;
        appInfo.processName = packageName;
        return appInfo;
    } 
 
    /** 
     * Non-Android accessor to set the application name. 
     * 
     * @param name 
     */ 
    public void setApplicationName(String name) {
        appName = name;
    } 
5
CodeRank

Related Android ApplicationInfo Questions & Answers:

See Code Examples for Android ApplicationInfo Methods: