android.app.Activity.getApplicationInfo()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(783)

本文整理了Java中android.app.Activity.getApplicationInfo()方法的一些代码示例,展示了Activity.getApplicationInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getApplicationInfo()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getApplicationInfo

Activity.getApplicationInfo介绍

暂无

代码示例

代码示例来源:origin: androidquery/androidquery

private ApplicationInfo getApplicationInfo(){
  
  if(ai == null){
    ai = act.getApplicationInfo();			
  }
  
  return ai;
}

代码示例来源:origin: stackoverflow.com

private static void killProcessesAround(Activity activity) throws NameNotFoundException {
  ActivityManager am = (ActivityManager)activity.getSystemService(Context.ACTIVITY_SERVICE);
  String myProcessPrefix = activity.getApplicationInfo().processName;
  String myProcessName = activity.getPackageManager().getActivityInfo(activity.getComponentName(), 0).processName;
  for (ActivityManager.RunningAppProcessInfo proc : am.getRunningAppProcesses()) {
    if (proc.processName.startsWith(myProcessPrefix) && !proc.processName.equals(myProcessName)) {
      android.os.Process.killProcess(proc.pid);
    }
  }
}

代码示例来源:origin: naman14/Timber

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
  // Sets color of entry in the system recents page
  try {
    ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
        (String) activity.getTitle(),
        ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
        color);
    activity.setTaskDescription(td);
  } catch (Exception ignored) {
  }
}

代码示例来源:origin: ac-pm/Inspeckage

String tree = Util.FileTree(activity.getApplicationInfo().dataDir, "");

代码示例来源:origin: com.googlecode.android-query/android-query

private ApplicationInfo getApplicationInfo(){
  
  if(ai == null){
    ai = act.getApplicationInfo();			
  }
  
  return ai;
}

代码示例来源:origin: com.uphyca/android-junit4-robolectric

/**
 * @return
 * @see android.content.ContextWrapper#getApplicationInfo()
 */
public ApplicationInfo getApplicationInfo() {
  return mActivity.getApplicationInfo();
}

代码示例来源:origin: stackoverflow.com

public AndroidPopup(Activity c){
  ApplicationInfo appInfo = c.getApplicationInfo();
  String gameName = (String) c.getPackageManager().getApplicationLabel(appInfo);
  // ...
}

代码示例来源:origin: iqiyi/Neptune

@Override
public ApplicationInfo getApplicationInfo() {
  if (mPluginContextWrapper != null) {
    return mPluginContextWrapper.getApplicationInfo();
  }
  return super.getApplicationInfo();
}

代码示例来源:origin: YarikSOffice/LanguageTest

public static Resources getTopLevelResources(Activity a) {
  try {
    return a.getPackageManager().getResourcesForApplication(a.getApplicationInfo());
  } catch (NameNotFoundException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: stackoverflow.com

private static String getExceptionDetails(Activity act, Exception e) {
  StackTraceElement[] stackTraceElement = e.getStackTrace();

  String fileName = "";
  String methodName = "";
  int lineNumber = 0;

  try {
    String packageName = act.getApplicationInfo().packageName;
    for (int i = 0; i < stackTraceElement.length; i++) {
      if (stackTraceElement[i].getClassName().startsWith(packageName))
      {
        fileName = stackTraceElement[i].getFileName();
        methodName = stackTraceElement[i].getMethodName();
        lineNumber = stackTraceElement[i].getLineNumber();
        break;
      }
    }
  } catch (Exception e2) {
  }

  return fileName + ":" + methodName + "():line "
      + String.valueOf(lineNumber);
}

代码示例来源:origin: zjns/PureNeteaseCloudMusic-Xposed

@SuppressWarnings("ResultOfMethodCallIgnored")
@SuppressLint("SetWorldReadable")
private void setWorldReadable() {
  File prefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs");
  File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");
  if (prefsFile.exists()) {
    prefsFile.setReadable(true, false);
  }
}

代码示例来源:origin: qq542391099/CameraSurfaceView-master

public void requestAllPermission(Activity activity) {
    if (Build.VERSION.SDK_INT >= 23 && activity.getApplicationInfo().targetSdkVersion >= 23) {
      Log.i(TAG, "request All Permission...");
      for (String permission : needPermissions) {
        if (!checkPermission(permission)) {
          requestPermission(activity, 0, permission);
        }
      }
    }
  }
}

代码示例来源:origin: marzika/Snapprefs

@Override
  public void onPause() {
    super.onPause();

    // Set preferences file permissions to be world readable
    File sharedPrefsDir = new File(getActivity().getApplicationInfo().dataDir, "data/shared_prefs");
    File sharedPrefsFile = new File(sharedPrefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");
    if (sharedPrefsFile.exists()) {
      sharedPrefsFile.setReadable(true, false);
    }
  }
}

代码示例来源:origin: rohanoid5/Muzesto

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
  // Sets color of entry in the system recents page
  try {
    ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
        (String) activity.getTitle(),
        ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
        color);
    activity.setTaskDescription(td);
  } catch (Exception ignored) {
  }
}

代码示例来源:origin: brainysoon/cyberCar

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
  // Sets color of entry in the system recents page
  try {
    ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
        (String) activity.getTitle(),
        ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
        color);
    activity.setTaskDescription(td);
  } catch (Exception ignored) {
  }
}

代码示例来源:origin: pylerSM/XInstaller

@Override
  public void onPause() {
    super.onPause();
    // Set preferences file permissions to be world readable
    File prefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs");
    File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");
    if (prefsFile.exists()) {
      prefsFile.setReadable(true, false);
    }
  }
}

代码示例来源:origin: pylerSM/XInternalSD

@Override
public void onPause() {
  super.onPause();
  // Set preferences file permissions to be world readable
  File prefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs");
  File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");
  if (prefsFile.exists()) {
    prefsFile.setReadable(true, false);
  }
}

代码示例来源:origin: pylerSM/XInstaller

@Override
public void onPause() {
  super.onPause();
  // Set legacy_preferences file permissions to be world readable
  File prefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs");
  File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");
  if (prefsFile.exists()) {
    prefsFile.setReadable(true, false);
  }
}

代码示例来源:origin: xuancao/DynamicSkin

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key) {
  int color;
  Bitmap icon = null;
  if (activity instanceof ATETaskDescriptionCustomizer) {
    final ATETaskDescriptionCustomizer customizer = (ATETaskDescriptionCustomizer) activity;
    color = customizer.getTaskDescriptionColor();
    icon = customizer.getTaskDescriptionIcon();
  } else {
    color = Config.primaryColor(activity, key);
  }
  // Task description requires fully opaque color
  color = Util.stripAlpha(color);
  // Default is app's launcher icon
  if (icon == null)
    icon = ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap();
  // Sets color of entry in the system recents page
  ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
      (String) activity.getTitle(), icon, color);
  activity.setTaskDescription(td);
}

代码示例来源:origin: garretyoder/app-theme-engine

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key) {
  int color = 0;
  Bitmap icon = null;
  if (activity instanceof ATETaskDescriptionCustomizer) {
    final ATETaskDescriptionCustomizer customizer = (ATETaskDescriptionCustomizer) activity;
    color = customizer.getTaskDescriptionColor();
    icon = customizer.getTaskDescriptionIcon();
    if (color == ATE.USE_DEFAULT)
      color = Config.primaryColor(activity, key);
  } else {
    color = Config.primaryColor(activity, key);
  }
  // Task description requires fully opaque color
  color = ATEUtil.stripAlpha(color);
  // Default is app's launcher icon
  if (icon == null)
    icon = ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap();
  // Sets color of entry in the system recents page
  ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
      (String) activity.getTitle(), icon, color);
  activity.setTaskDescription(td);
}

相关文章

Activity类方法