Java Code Examples for android.content.Context#startActivities()

The following examples show how to use android.content.Context#startActivities() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
private static void startActivities(final Intent[] intents,
                                    final Context context,
                                    @Nullable final Bundle options) {
    if (!(context instanceof Activity)) {
        for (Intent intent : intents) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
    }
    if (options != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        context.startActivities(intents, options);
    } else {
        context.startActivities(intents);
    }
}
 
Example 2
Source File: OpenAction.java    From opentasks with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(Context context, ContentProviderClient contentProviderClient, RowDataSnapshot<TaskContract.Instances> rowSnapshot, Uri taskUri) throws RemoteException, OperationApplicationException
{
    // TODO: check if it's still a good idea to build a custom stack
    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(Intent.ACTION_VIEW);
    resultIntent.setData(taskUri);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    context.startActivities(stackBuilder.getIntents());
}
 
Example 3
Source File: SchemeSecondActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void reStartActivity(Intent intent, Context context) {
    Intent[] intents = new Intent[2];
    Intent mainIntent = new Intent(context, MainActivity.class);
    mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[0] = mainIntent;
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[1] = intent;
    context.startActivities(intents);
}
 
Example 4
Source File: SchemeFirstActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void reStartActivity(Intent intent, Context context) {
    Intent[] intents = new Intent[2];
    Intent mainIntent = new Intent(context, MainActivity.class);
    mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[0] = mainIntent;
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[1] = intent;
    context.startActivities(intents);
}
 
Example 5
Source File: SchemeActivity.java    From YCVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 注意,为何要这样跳转,首先需要先跳转首页,然后在跳转到指定页面,那么回来的时候始终是首页Main页面
 * @param intent                            intent
 * @param context                           上下文
 */
public void reStartActivity(Intent intent, Context context) {
    Intent[] intents = new Intent[2];
    Intent mainIntent = new Intent(context, MainActivity.class);
    mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[0] = mainIntent;
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intents[1] = intent;
    context.startActivities(intents);
}
 
Example 6
Source File: NotificationReceiver.java    From A-week-to-develop-android-app-plan with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	// 判断app进程是否存活
	if (SystemUtils.isAppAlive(context, "net.coollet.infzmreader")) {
		Log.i("NotificationReceiver", "the app process is alive");
		Intent mainIntent = new Intent(context, MainActivity.class);
		mainIntent.putExtra("ID", intent.getIntExtra("ID", 0));
		mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

		Intent detailIntent = new Intent(context,
				MainActivity.class);
		detailIntent.putExtra("ID", intent.getIntExtra("ID", 0));

		Intent[] intents = { mainIntent, detailIntent };

		context.startActivities(intents);
	} else {
		Log.i("NotificationReceiver", "the app process is dead");
		Intent launchIntent = context.getPackageManager()
				.getLaunchIntentForPackage("net.coollet.infzmreader");
		launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
				| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
		launchIntent.putExtra("ID", intent.getIntExtra("ID", 0));
		context.startActivity(launchIntent);
	}
}
 
Example 7
Source File: b.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
static void a(Context context, Intent aintent[])
{
    context.startActivities(aintent);
}
 
Example 8
Source File: c.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static void a(Context context, Intent aintent[], Bundle bundle)
{
    context.startActivities(aintent, bundle);
}
 
Example 9
Source File: ContextCompatHoneycomb.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
static void startActivities(Context context, Intent[] intents) {
    context.startActivities(intents);
}
 
Example 10
Source File: ContextCompatJellybean.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void startActivities(Context context, Intent[] intents, Bundle options) {
    context.startActivities(intents, options);
}
 
Example 11
Source File: ContextCompatHoneycomb.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
static void startActivities(Context context, Intent[] intents) {
    context.startActivities(intents);
}
 
Example 12
Source File: ContextCompatJellybean.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static void startActivities(Context context, Intent[] intents, Bundle options) {
    context.startActivities(intents, options);
}
 
Example 13
Source File: ContextCompatHoneycomb.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
static void startActivities(Context context, Intent[] intents) {
    context.startActivities(intents);
}
 
Example 14
Source File: ContextCompatJellybean.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static void startActivities(Context context, Intent[] intents, Bundle options) {
    context.startActivities(intents, options);
}
 
Example 15
Source File: ContextCompatHoneycomb.java    From guideshow with MIT License 4 votes vote down vote up
static void startActivities(Context context, Intent[] intents) {
    context.startActivities(intents);
}
 
Example 16
Source File: ContextCompatJellybean.java    From guideshow with MIT License 4 votes vote down vote up
public static void startActivities(Context context, Intent[] intents, Bundle options) {
    context.startActivities(intents, options);
}