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

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

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

Activity.startActivityIfNeeded介绍

暂无

代码示例

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

/**
 * @param intent
 * @param requestCode
 * @return
 * @see android.app.Activity#startActivityIfNeeded(android.content.Intent,
 *      int)
 */
public boolean startActivityIfNeeded(Intent intent,
                   int requestCode) {
  return mActivity.startActivityIfNeeded(intent, requestCode);
}

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

@Override
public boolean startActivityIfNeeded(android.content.Intent intent0, int int1) {
  return mOriginActivity.startActivityIfNeeded(intent0, int1);
}

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

/**
 * @param intent
 * @param requestCode
 * @param options
 * @return
 * @see android.app.Activity#startActivityIfNeeded(android.content.Intent,
 *      int, android.os.Bundle)
 */
public boolean startActivityIfNeeded(Intent intent,
                   int requestCode,
                   Bundle options) {
  return mActivity.startActivityIfNeeded(intent, requestCode, options);
}

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

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public boolean startActivityIfNeeded(android.content.Intent intent0, int int1, android.os.Bundle bundle2) {
  return mOriginActivity.startActivityIfNeeded(intent0, int1, bundle2);
}

代码示例来源:origin: ManbangGroup/Phantom

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public boolean startActivityIfNeeded(@RequiresPermission @NonNull Intent intent, int requestCode,
                   @Nullable Bundle options) {
  return mContentProxy.getContext().startActivityIfNeeded(mContentProxy.setActivityIntentExtra(intent),
      requestCode, options);
}

代码示例来源:origin: ManbangGroup/Phantom

@Override
public boolean startActivityIfNeeded(@RequiresPermission @NonNull Intent intent, int requestCode) {
  return mContentProxy.getContext()
      .startActivityIfNeeded(mContentProxy.setActivityIntentExtra(intent), requestCode);
}

代码示例来源:origin: derry/delion

@Override
public boolean startActivityIfNeeded(Intent intent) {
  boolean isExternalProtocol = !UrlUtilities.isAcceptedScheme(intent.getDataString());
  boolean hasDefaultHandler = hasDefaultHandler(intent);
  try {
    // For a URL chrome can handle and there is no default set, handle it ourselves.
    if (!hasDefaultHandler) {
      if (!TextUtils.isEmpty(mClientPackageName) && isPackageSpecializedHandler(
          mApplicationContext, mClientPackageName, intent)) {
        intent.setPackage(mClientPackageName);
      } else if (!isExternalProtocol) {
        return false;
      }
    }
    // If android fails to find a handler, handle it ourselves.
    Context context = getAvailableContext();
    if (context instanceof Activity
        && ((Activity) context).startActivityIfNeeded(intent, -1)) {
      mHasActivityStarted = true;
      return true;
    }
    return false;
  } catch (RuntimeException e) {
    logTransactionTooLargeOrRethrow(e, intent);
    return false;
  }
}

代码示例来源:origin: derry/delion

@Override
public boolean startActivityIfNeeded(Intent intent) {
  boolean activityWasLaunched;
  // Only touches disk on Kitkat. See http://crbug.com/617725 for more context.
  StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
  StrictMode.allowThreadDiskReads();
  try {
    forcePdfViewerAsIntentHandlerIfNeeded(mApplicationContext, intent);
    Context context = getAvailableContext();
    if (context instanceof Activity) {
      activityWasLaunched = ((Activity) context).startActivityIfNeeded(intent, -1);
    } else {
      activityWasLaunched = false;
    }
    if (activityWasLaunched) recordExternalNavigationDispatched(intent);
    return activityWasLaunched;
  } catch (RuntimeException e) {
    logTransactionTooLargeOrRethrow(e, intent);
    return false;
  } finally {
    StrictMode.setThreadPolicy(oldPolicy);
  }
}

相关文章

Activity类方法