下面列出了android.support.v4.content.ContextCompat#startActivities ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
/**
* 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);
}
}
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);
}
}
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);
}
}
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);
}
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);
}