当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationInfo类代码示例

本文整理汇总了Java中android.content.pm.ApplicationInfo的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInfo类的具体用法?Java ApplicationInfo怎么用?Java ApplicationInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationInfo类属于android.content.pm包,在下文中一共展示了ApplicationInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: install

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
public static void install(Context context,
                           String packageName,
                           int versionCode, String versionName,
                           @Nullable String signingCert,
                           @Nullable String hash) {
    PackageInfo info = new PackageInfo();
    info.packageName = packageName;
    info.versionCode = versionCode;
    info.versionName = versionName;
    info.applicationInfo = new ApplicationInfo();
    info.applicationInfo.publicSourceDir = "/tmp/mock-location";
    if (signingCert != null) {
        info.signatures = new Signature[]{new Signature(signingCert)};
    }

    String hashType = "sha256";
    if (hash == null) {
        hash = "00112233445566778899aabbccddeeff";
    }

    InstalledAppProviderService.insertAppIntoDb(context, info, hashType, hash);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:23,代码来源:InstalledAppTestUtils.java

示例2: onReceivedSslError

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
开发者ID:Andy-Ta,项目名称:COB,代码行数:34,代码来源:SystemWebViewClient.java

示例3: handleDocumentsProvider

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
private void handleDocumentsProvider(ProviderInfo info) {
    // Ignore stopped packages for now; we might query them
    // later during UI interaction.
    if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
        if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
        mTaskStoppedAuthorities.add(info.authority);
        return;
    }

    // Try using cached roots if filtering
    boolean cacheHit = false;
    if (mAuthority != null && !mAuthority.equals(info.authority)) {
        synchronized (mLock) {
            if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
                if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
                cacheHit = true;
            }
        }
    }

    // Cache miss, or loading everything
    if (!cacheHit) {
        mTaskRoots.putAll(info.authority,
                loadRootsForAuthority(mContext.getContentResolver(), info.authority));
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:27,代码来源:RootsCache.java

示例4: parse

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
public List<ConfigModule> parse() {
    List<ConfigModule> modules = new ArrayList<ConfigModule>();
    try {
        ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
                context.getPackageName(), PackageManager.GET_META_DATA);
        if (appInfo.metaData != null) {
            for (String key : appInfo.metaData.keySet()) {
                if (MODULE_VALUE.equals(appInfo.metaData.get(key))) {
                    modules.add(parseModule(key));
                }
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Unable to find metadata to parse ConfigModule", e);
    }

    return modules;
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:19,代码来源:ManifestParser.java

示例5: getIcon

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
private int getIcon(Context context){

            final PackageManager packageManager = context.getPackageManager();
            ApplicationInfo appInfo = null;
            try {
                appInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            if (appInfo != null){
                return appInfo.icon;
            }
            return 0;
        }
 
开发者ID:androidstarjack,项目名称:ServiceDownLoadApp-master,代码行数:15,代码来源:UpdateService.java

示例6: isPrivilegedApp

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
static boolean isPrivilegedApp(int callerUid, int callerPid) {
    if (callerUid == Process.SYSTEM_UID || callerUid == 0 ||
            callerPid == Process.myPid() || callerPid == 0) {
        return true;
    }

    IPackageManager pm = AppGlobals.getPackageManager();
    try {
        return (pm.getPrivateFlagsForUid(callerUid) & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
                != 0;
    } catch (RemoteException ex) {
        Slog.e(IntentFirewall.TAG, "Remote exception while retrieving uid flags",
                ex);
    }

    return false;
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:18,代码来源:SenderFilter.java

示例7: isMetaDataSet

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
private boolean isMetaDataSet() {
  Context context = Leanplum.getContext();
  try {
    ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
        context.getPackageName(), PackageManager.GET_META_DATA);
    if (appInfo != null) {
      if (appInfo.metaData != null) {
        Object value = appInfo.metaData.get(METADATA);
        if (value != null) {
          return true;
        }
      }
    }
    return false;
  } catch (NameNotFoundException e) {
    return false;
  }
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:19,代码来源:LocationManagerImplementation.java

示例8: pushClientInfoToFrontOfQueue

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
void pushClientInfoToFrontOfQueue()
{
	if (DEBUG_LOGGER)
		Log.v("NSLogger", "Pushing client info to front of queue");

	LogMessage lm = new LogMessage(LogMessage.LOGMSG_TYPE_CLIENTINFO, nextSequenceNumber.getAndIncrement());
	lm.addString(Build.MANUFACTURER + " " + Build.MODEL, LogMessage.PART_KEY_CLIENT_MODEL);
	lm.addString("Android", LogMessage.PART_KEY_OS_NAME);
	lm.addString(Build.VERSION.RELEASE, LogMessage.PART_KEY_OS_VERSION);
	lm.addString(Secure.getString(currentContext.getContentResolver(), Secure.ANDROID_ID), LogMessage.PART_KEY_UNIQUEID);
	ApplicationInfo ai = currentContext.getApplicationInfo();
	String appName = ai.packageName;
	if (appName == null)
	{
		appName = ai.processName;
		if (appName == null)
		{
			appName = ai.taskAffinity;
			if (appName == null)
				appName = ai.toString();
		}
	}
	lm.addString(appName, LogMessage.PART_KEY_CLIENT_NAME);
	logs.add(0, lm);
	clientInfoAdded = true;
}
 
开发者ID:intari,项目名称:CustomLogger,代码行数:27,代码来源:NSLoggerClient.java

示例9: getMatchingDrawables

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
List<String> getMatchingDrawables(String packageName) {
    List<String> matchingDrawables = new ArrayList<>();
    ApplicationInfo info = null;
    try {
        info = mPackageManager.getApplicationInfo(packageName, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    String packageLabel = (info != null ? mPackageManager.getApplicationLabel(info).toString()
            : packageName).replaceAll("[^a-zA-Z]", "").toLowerCase().trim();
    for (String drawable : mDrawables) {
        if (drawable == null) continue;
        String filteredDrawable = drawable.replaceAll("[^a-zA-Z]", "").toLowerCase().trim();
        if (filteredDrawable.length() > 2 && (packageLabel.contains(filteredDrawable)
                || filteredDrawable.contains(packageLabel))) {
            matchingDrawables.add(drawable);
        }
    }
    return matchingDrawables;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:IconsManager.java

示例10: processRestarted

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
@Override
public void processRestarted(String packageName, String processName, int userId) {
    int callingPid = getCallingPid();
    int appId = VAppManagerService.get().getAppId(packageName);
    int uid = VUserHandle.getUid(userId, appId);
    synchronized (this) {
        ProcessRecord app = findProcessLocked(callingPid);
        if (app == null) {
            ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId);
            appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE;
            String stubProcessName = getProcessName(callingPid);
            int vpid = parseVPid(stubProcessName);
            if (vpid != -1) {
                performStartProcessLocked(uid, vpid, appInfo, processName);
            }
        }
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:19,代码来源:VActivityManagerService.java

示例11: init

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
private void init() {
    String pkgName = pkgInfo.packageName;
    // Check if there is already a package on the device with this name
    // but it has been renamed to something else.
    final String[] oldName = pm.canonicalToCurrentPackageNames(new String[]{pkgName});
    if (oldName != null && oldName.length > 0 && oldName[0] != null) {
        pkgName = oldName[0];
        pkgInfo.packageName = pkgName;
        pkgInfo.applicationInfo.packageName = pkgName;
    }
    // Check if package is already installed
    try {
        // This is a little convoluted because we want to get all uninstalled
        // apps, but this may include apps with just data, and if it is just
        // data we still want to count it as "installed".
        //noinspection WrongConstant (lint is actually wrong here!)
        installedAppInfo = pm.getApplicationInfo(pkgName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        if ((installedAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
            installedAppInfo = null;
        }
    } catch (PackageManager.NameNotFoundException e) {
        installedAppInfo = null;
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:26,代码来源:AppDiff.java

示例12: getMetaData

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
public static String getMetaData(Context context, @NonNull String key) {
    String metaDataValue = "";
    try {
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo != null && applicationInfo.metaData != null) {
                metaDataValue = applicationInfo.metaData.getString(key);
            }
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    return metaDataValue;
}
 
开发者ID:jiajieshen,项目名称:AndroidDevSamples,代码行数:18,代码来源:ApplicationUtil.java

示例13: beforeInvoke

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
@Override
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
    //API 2.3,15,16,17,18,19, 21
/* public boolean bindBackupAgent(ApplicationInfo appInfo, int backupRestoreMode)
    throws RemoteException;*/
    final int index = 0;
    if (args != null && args.length > index) {
        if (args[index] != null && args[index] instanceof ApplicationInfo) {
            ApplicationInfo appInfo = (ApplicationInfo) args[index];
            if (isPackagePlugin(appInfo.packageName)) {
                args[index] = mHostContext.getApplicationInfo();
            }
        }
    }
    return super.beforeInvoke(receiver, method, args);
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:17,代码来源:IActivityManagerHookHandle.java

示例14: buildAppLinkDataForNavigation

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
private Bundle buildAppLinkDataForNavigation(Context context) {
    Bundle data = new Bundle();
    Bundle refererAppLinkData = new Bundle();
    if (context != null) {
        String refererAppPackage = context.getPackageName();
        if (refererAppPackage != null) {
            refererAppLinkData.putString(KEY_NAME_REFERER_APP_LINK_PACKAGE, refererAppPackage);
        }
        ApplicationInfo appInfo = context.getApplicationInfo();
        if (appInfo != null) {
            String refererAppName = context.getString(appInfo.labelRes);
            if (refererAppName != null) {
                refererAppLinkData.putString("app_name", refererAppName);
            }
        }
    }
    data.putAll(getAppLinkData());
    data.putString("target_url", getAppLink().getSourceUrl().toString());
    data.putString("version", "1.0");
    data.putString(KEY_NAME_USER_AGENT, "Bolts Android 1.2.1");
    data.putBundle(KEY_NAME_REFERER_APP_LINK, refererAppLinkData);
    data.putBundle("extras", getExtras());
    return data;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:AppLinkNavigation.java

示例15: getAppName

import android.content.pm.ApplicationInfo; //导入依赖的package包/类
@ScriptInterface
public String getAppName(String packageName) {
    PackageManager packageManager = mContext.getPackageManager();
    try {
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
        CharSequence appName = packageManager.getApplicationLabel(applicationInfo);
        return appName == null ? null : appName.toString();
    } catch (PackageManager.NameNotFoundException e) {
        return null;
    }
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:12,代码来源:AppUtils.java


注:本文中的android.content.pm.ApplicationInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。