android.content.Intent.clone()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(222)

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

Intent.clone介绍

暂无

代码示例

代码示例来源:origin: 80945540/FreeBook

ArrayList<Intent> getIntents() {
  ArrayList<Intent> intentList = new ArrayList<>();
  for (WeakReference<Activity> activityWeakReference : mRunningActivities) {
    if (activityWeakReference == null)
      continue;
    Activity tmpActivity = activityWeakReference.get();
    if (tmpActivity == null)
      continue;
    intentList.add((Intent) tmpActivity.getIntent().clone());
  }
  return intentList;
}

代码示例来源:origin: Countly/countly-sdk-android

private static Intent actionIntent(Context context, Intent notificationIntent, Message message, int index) {
  Intent intent;
  if (notificationIntent == null) {
    intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
  } else {
    intent = (Intent) notificationIntent.clone();
  }
  Bundle bundle = new Bundle();
  bundle.putParcelable(EXTRA_MESSAGE, message);
  intent.putExtra(EXTRA_MESSAGE, bundle);
  intent.putExtra(EXTRA_ACTION_INDEX, index);
  return intent;
}

代码示例来源:origin: klinker41/android-smsmms

@Override
  public void onReceive(Context context, Intent intent) {
    context.unregisterReceiver(this);
    PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MMS DownloadReceiver");
    wakeLock.acquire(60 * 1000);
    Intent newIntent = (Intent) intent.clone();
    newIntent.setAction(MmsReceivedReceiver.MMS_RECEIVED);
    BroadcastUtils.sendExplicitBroadcast(context, newIntent, MmsReceivedReceiver.MMS_RECEIVED);
  }
}

代码示例来源:origin: 80945540/LCRapidDevelop

ArrayList<Intent> getIntents() {
  ArrayList<Intent> intentList = new ArrayList<>();
  for (WeakReference<Activity> activityWeakReference : mRunningActivities) {
    if (activityWeakReference == null)
      continue;
    Activity tmpActivity = activityWeakReference.get();
    if (tmpActivity == null)
      continue;
    intentList.add((Intent) tmpActivity.getIntent().clone());
  }
  return intentList;
}

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

public Intent generateTorrentIntent(Context context, String action, Intent intent) {
  final PackageManager packageManager = context.getPackageManager();
  List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent,
      PackageManager.MATCH_DEFAULT_ONLY);
  if (resolveInfo.size() > 0) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    for (ResolveInfo r : resolveInfo) {
      Intent progIntent = (Intent)intent.clone();
      String packageName = r.activityInfo.packageName;

      progIntent.setPackage(packageName);
      if (r.activityInfo.packageName.contains("torrent"))
        targetedShareIntents.add(progIntent);

    }
    if (targetedShareIntents.size() > 0) {
      Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0),
          "Select app to share");

      chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
          targetedShareIntents.toArray(new Parcelable[] {}));

      return chooserIntent;
    }
  }
  return null;
}

代码示例来源:origin: mcsong/FilteredIntent

/**
 * Search and return filtered intent from all of activities
 *
 * @param context
 * @param intent
 * @param filter
 * @return
 */
public static Intent filter(Context context, Intent intent, String filter) {
  if(context == null || intent == null) {
    return null;
  }
  List<ResolveInfo> resInfos = context.getPackageManager().queryIntentActivities(intent, 0);
  if(resInfos == null || resInfos.isEmpty()) {
    return null;
  }
  Intent resultIntent = (Intent)intent.clone();
  ActivityInfo activityInfo;
  for (ResolveInfo info : resInfos) {
    activityInfo = info.activityInfo;
    if (activityInfo.packageName.toLowerCase().contains(filter) || activityInfo.name.toLowerCase().contains(filter) ) {
      resultIntent.setComponent(new ComponentName(activityInfo.packageName, activityInfo.name));
      return resultIntent;
    }
  }
  return null;
}

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

private static Intent screenshotPermission = null;

protected static void getScreenshotPermission() {
  try {
    if (hasScreenshotPermission()) {
      if(null != mediaProjection) {
        mediaProjection.stop();
        mediaProjection = null;
      }
      mediaProjection = mediaProjectionManager.getMediaProjection(Activity.RESULT_OK, (Intent) screenshotPermission.clone()); 
    } else {
      openScreenshotPermissionRequester();
    }
  } catch (final RuntimeException ignored) {
    openScreenshotPermissionRequester();
  }
}

protected static void openScreenshotPermissionRequester(){
  final Intent intent = new Intent(context, AcquireScreenshotPermissionIntent.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  context.startActivity(intent);
}


protected static void setScreenshotPermission(final Intent permissionIntent) {
  screenshotPermission = permissionIntent;
}

代码示例来源:origin: abrenoch/hyperion-android-grabber

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_MEDIA_PROJECTION) {
    if (resultCode != Activity.RESULT_OK) {
      Toast.makeText(this, R.string.toast_must_give_permission, Toast.LENGTH_SHORT).show();
      if (mRecorderRunning) {
        stopScreenRecorder();
      }
      setImageViews(false, true);
      return;
    }
    Log.i(TAG, "Starting screen capture");
    startScreenRecorder(resultCode, (Intent) data.clone());
    mRecorderRunning = true;
  }
}

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

Intent targetedShareIntent = (Intent) prototype.clone();
targetedShareIntent.setPackage(metaInfo.get("packageName"));
targetedShareIntent.setClassName(metaInfo.get("packageName"), metaInfo.get("className"));

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

Intent targetedShareIntent = (Intent) prototype.clone();
targetedShareIntent.setPackage(metaInfo.get("packageName"));
targetedShareIntent.setClassName(metaInfo.get("packageName"), metaInfo.get("className"));

代码示例来源:origin: robotoworks/mechanoid

public int executeBatch(Intent... intents) {
  if(intents.length == 0) {
    return -1;
  }
  
  ArrayList<Intent> intentList = new ArrayList<Intent>();
  
  Intent batchIntent = new Intent(OperationService.ACTION_BATCH);
  ComponentName c = intents[0].getComponent();
  batchIntent.setClassName(c.getPackageName(), c.getClassName());
  batchIntent.putExtra(OperationService.EXTRA_BRIDGE_MESSENGER, messenger);
  
  int id = createRequestId();
  for(Intent intent : intents) {
    Intent clonedIntent = (Intent) intent.clone();
    intentList.add(clonedIntent);
  }
  batchIntent.putExtra(OperationService.EXTRA_REQUEST_ID, id);
  batchIntent.putExtra(OperationService.EXTRA_BATCH, intentList);
  
  if(mPaused) {
    mPausedRequests.put(id, batchIntent);
  } else {
    mPendingRequests.put(id, batchIntent);
    Mechanoid.startService(batchIntent);
  }
  
  return id;
}

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

Intent targetedShareIntent = (Intent) prototype.clone();
targetedShareIntent.setPackage(metaInfo.get("packageName"));
targetedShareIntent.setClassName(

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

Intent targetedShareIntent = (Intent) prototype.clone();
targetedShareIntent.setPackage(metaInfo.get("packageName"));
targetedShareIntent.setClassName(

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

Intent targetedShareIntent = (Intent) prototype.clone();
if (metaInfo.get("packageName").equals(CLIPBOARD)) {
  targetedShareIntent.setPackage(metaInfo.get("packageName"));

代码示例来源:origin: robotoworks/mechanoid

Intent clonedIntent = (Intent) intent.clone();

代码示例来源:origin: abrenoch/hyperion-android-grabber

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_INITIAL_SETUP){
    if (resultCode == RESULT_OK){
      if (!initIfConfigured()){
        startSetup();
      }
    } else {
      finish();
    }
    return;
  }
  if (requestCode == REQUEST_MEDIA_PROJECTION) {
    if (resultCode != Activity.RESULT_OK) {
      Toast.makeText(this, R.string.toast_must_give_permission, Toast.LENGTH_SHORT).show();
      if (mRecorderRunning) {
        stopScreenRecorder();
      }
      setImageViews(false, true);
      return;
    }
    Log.i(TAG, "Starting screen capture");
    startScreenRecorder(resultCode, (Intent) data.clone());
    mRecorderRunning = true;
  }
}

代码示例来源:origin: michael-rapp/AndroidBottomSheet

/**
 * Adds the apps, which are able to handle a specific intent, as items to the bottom sheet. This
 * causes all previously added items to be removed. When an item is clicked, the corresponding
 * app is started.
 *
 * @param activity
 *         The activity, the bottom sheet belongs to, as an instance of the class {@link
 *         Activity}. The activity may not be null
 * @param intent
 *         The intent as an instance of the class {@link Intent}. The intent may not be null
 */
public final void setIntent(@NonNull final Activity activity, @NonNull final Intent intent) {
  Condition.INSTANCE.ensureNotNull(activity, "The activity may not be null");
  Condition.INSTANCE.ensureNotNull(intent, "The intent may not be null");
  removeAllItems();
  PackageManager packageManager = activity.getPackageManager();
  List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0);
  for (int i = 0; i < resolveInfos.size(); i++) {
    ResolveInfo resolveInfo = resolveInfos.get(i);
    addItem(i, resolveInfo.loadLabel(packageManager), resolveInfo.loadIcon(packageManager));
  }
  setOnItemClickListener(
      createIntentClickListener(activity, (Intent) intent.clone(), resolveInfos));
}

代码示例来源:origin: 80945540/LCRapidDevelop

@Override
  public void run() {
    RecoveryStore.getInstance().putActivity(activity);
    Object o = activity.getIntent().clone();
    RecoveryStore.getInstance().setIntent((Intent) o);
  }
});

代码示例来源:origin: 80945540/FreeBook

@Override
  public void run() {
    RecoveryStore.getInstance().putActivity(activity);
    Object o = activity.getIntent().clone();
    RecoveryStore.getInstance().setIntent((Intent) o);
  }
});

代码示例来源:origin: Countly/countly-sdk-android

Intent actionIntent = (Intent) proxy.clone();
actionIntent.putExtra(CountlyMessaging.EXTRA_ACTION_INDEX, button.index);
builder.addAction(0, button.title, PendingIntent.getActivity(getApplicationContext(), button.index, actionIntent, PendingIntent.FLAG_UPDATE_CURRENT));

相关文章

Intent类方法