android.support.v4.content.ContextCompat#startActivities ( )源码实例Demo

下面列出了android.support.v4.content.ContextCompat#startActivities ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SmartGo   文件: BaseActivityLauncher.java
@Override
public void goReally(final Context context,final Intent intent){
    if(isAvailable(context,intent)) {
        final ActivityOptionsCompat options = mActivityOptionsBox.get();
        Bundle optionsBundle = null;
        if(options != null) {
            optionsBundle = options.toBundle();
        }

        if(context instanceof Activity) {
            ActivityCompat.startActivityForResult((Activity) context, intent, mRequestCode, optionsBundle);
        }else {
            ContextCompat.startActivities(context,new Intent[]{intent},optionsBundle);
        }
    }else{
        SmartGoLog.e("have no resolved activity : " + intent);
    }
}
 
源代码2 项目: CodenameOne   文件: TaskStackBuilder.java
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
源代码3 项目: adt-leanback-support   文件: TaskStackBuilder.java
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
源代码4 项目: android-recipes-app   文件: TaskStackBuilder.java
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
源代码5 项目: V.FlyoutTest   文件: TaskStackBuilder.java
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
源代码6 项目: guideshow   文件: TaskStackBuilder.java
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
源代码7 项目: letv   文件: TaskStackBuilder.java
public void startActivities(Bundle options) {
    if (this.mIntents.isEmpty()) {
        throw new IllegalStateException("No intents added to TaskStackBuilder; cannot startActivities");
    }
    Intent[] intents = (Intent[]) this.mIntents.toArray(new Intent[this.mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(268484608);
    if (!ContextCompat.startActivities(this.mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(268435456);
        this.mSourceContext.startActivity(topIntent);
    }
}
 
源代码8 项目: MiBandDecompiled   文件: TaskStackBuilder.java
public void startActivities(Bundle bundle)
{
    if (c.isEmpty())
    {
        throw new IllegalStateException("No intents added to TaskStackBuilder; cannot startActivities");
    }
    Intent aintent[] = (Intent[])c.toArray(new Intent[c.size()]);
    aintent[0] = (new Intent(aintent[0])).addFlags(0x1000c000);
    if (!ContextCompat.startActivities(d, aintent, bundle))
    {
        Intent intent = new Intent(aintent[-1 + aintent.length]);
        intent.addFlags(0x10000000);
        d.startActivity(intent);
    }
}
 
源代码9 项目: PowerFileExplorer   文件: ContextUtil.java
public static boolean startActivities(Intent[] intents, Bundle options) {
    for (Intent intent : intents)
        if (intent != null)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return ContextCompat.startActivities(Base.getContext(), intents, options);
}
 
源代码10 项目: PowerFileExplorer   文件: ContextUtil.java
public static boolean startActivities(Intent[] intents) {
    for (Intent intent : intents)
        if (intent != null)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return ContextCompat.startActivities(Base.getContext(), intents);
}