Example usage for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK.

Prototype

int FLAG_ACTIVITY_MULTIPLE_TASK

To view the source code for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK.

Click Source Link

Document

This flag is used to create a new task and launch an activity into it.

Usage

From source file:com.commonsware.android.tte.MainActivity.java

@Override
public void launchInNewWindow(Uri document) {
    adapter.remove(document);/* w ww.j a v a2 s .co  m*/

    Intent i = new Intent(this, MainActivity.class).setAction(ACTION_NEW_WINDOW).setData(document)
            .setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

    startActivity(i);
}

From source file:com.android.projectz.teamrocket.thebusapp.adapters.MainRecyclerAdapter.java

@Override
public void onBindViewHolder(final MainRecyclerAdapter.ViewHolder holder, final int position) {
    int lastPosition = -1;
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(context,
                (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
        holder.itemView.startAnimation(animation);
        lastPosition = position;// w  w w.  jav a2 s .co  m
    }

    if (SharedPreferencesUtils.getSelectedTheme(context).equals("ThemeDark")) {
        holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.cardview_dark_background));
        holder.txtTitle.setTextColor(ContextCompat.getColor(context, android.R.color.primary_text_dark));
        holder.txtSubtitle.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_dark));
        holder.txtOther.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_dark));
        image = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_arrow_row));
        DrawableCompat.setTint(image, context.getResources().getColor(R.color.iconDark));
    } else {
        holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.cardview_light_background));
        holder.txtTitle.setTextColor(ContextCompat.getColor(context, android.R.color.primary_text_light));
        holder.txtSubtitle.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_light));
        holder.txtOther.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_light));
        image = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_arrow_row));
        DrawableCompat.setTint(image, context.getResources().getColor(R.color.iconLight));
    }

    holder.txtTitle.setText(myObjects.get(position).getTextTitle());
    holder.txtSubtitle.setText(myObjects.get(position).getTextSubtitle());
    holder.txtOther.setText(myObjects.get(position).getTextOther());
    holder.imageView.setImageResource(myObjects.get(position).getImageId());
    holder.arrowRow.setImageDrawable(image);

    //ascoltatore del *tap* sulla card
    holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(context, "Loading...", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(context, DetailViewerActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); //senza di esso va in crash, perch bisogna creare l'intent come se fosse una nuova activity
            intent.putExtra("title", myObjects.get(position).getTextTitle());
            intent.putExtra("subtitle", myObjects.get(position).getTextSubtitle());
            intent.putExtra("other", myObjects.get(position).getTextOther());
            intent.putExtra("fermataId", myObjects.get(position).getFermataId());
            ArrayList<String> holderData = new ArrayList<String>();
            holderData.add(myObjects.get(position).getTextTitle());
            holderData.add(myObjects.get(position).getTextSubtitle());
            holderData.add(myObjects.get(position).getTextOther());
            intent.putStringArrayListExtra("holderData", holderData);
            context.startActivity(intent);
        }
    });

    //MainActivity.recyclerView.scrollToPosition(myObjects.get(position).isNear != -1 ? position : null);
}

From source file:com.abhijitvalluri.android.fitnotifications.HomeFragment.java

private void initializeButtons() {
    initializeServiceButtons();//  w  ww. ja v  a 2s.  c  om
    initializeDemoButton();
    initializeEnableNotificationButton();

    mImproveTransliterationTV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String uriText = "mailto:android@abhijitvalluri.com" + "?subject="
                    + Uri.encode("Improve Transliterations for <SPECIFY_LANGUAGE>") + "&body="
                    + Uri.encode("<MESSAGE>");

            Uri uri = Uri.parse(uriText);

            Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
            sendIntent.setData(uri);
            startActivity(Intent.createChooser(sendIntent, "Send email"));
        }
    });

    mRateAppTV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse("market://details?id=" + Constants.PACKAGE_NAME);
            Intent gotoPlayStore = new Intent(Intent.ACTION_VIEW, uri);
            // To count with Play market backstack, After pressing back button,
            // to taken back to our application, we need to add following flags to intent.
            gotoPlayStore.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            try {
                startActivity(gotoPlayStore);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + Constants.PACKAGE_NAME)));
            }
        }
    });
}

From source file:saschpe.birthdays.fragment.SocialFragment.java

/**
 * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
 * has returned, but before any saved state has been restored in to the view.
 * This gives subclasses a chance to initialize themselves once
 * they know their view hierarchy has been completely created.  The fragment's
 * view hierarchy is not however attached to its parent at this point.
 *
 * @param view               The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
 * @param savedInstanceState If non-null, this fragment is being re-constructed
 *///from   w  w w  .j a v a 2s.c om
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    provideFeedback.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String subject = getString(R.string.feedback_mail_subject_template, getString(R.string.app_name));

            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", SUPPORT_EMAIL_ADDRESS[0], null))
                            .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, "")
                            .putExtra(Intent.EXTRA_EMAIL, SUPPORT_EMAIL_ADDRESS);
            startActivity(Intent.createChooser(emailIntent, view.getContext().getString(R.string.send_email)));
        }
    });
    followTwitter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("twitter://user?screen_name=" + TWITTER_NAME)));
            } catch (ActivityNotFoundException e) {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + TWITTER_NAME)));
            }
        }
    });
    rateOnPlayStore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // To count with Play market back stack, After pressing back button,
            // to taken back to our application, we need to add following flags to intent.
            int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
            if (Build.VERSION.SDK_INT >= 21) {
                flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
            } else {
                //noinspection deprecation
                flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
            }
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName))
                    .addFlags(flags);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + packageName)));
            }
        }
    });
    recommendToFriend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String subject = getString(R.string.get_app_template, getString(R.string.app_name));
            String body = Uri.parse("http://play.google.com/store/apps/details?id=" + packageName).toString();

            Intent sharingIntent = new Intent(Intent.ACTION_SEND).setType("text/plain")
                    .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, body);
            startActivity(Intent.createChooser(sharingIntent, view.getContext().getString(R.string.share_via)));
        }
    });
    forkOnGithub.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(Intent.ACTION_VIEW)
                    .setData(Uri.parse("https://github.com/saschpe/BirthdayCalendar")));
        }
    });
}

From source file:net.gsantner.opoc.util.ActivityUtils.java

public void showGooglePlayEntryForThisApp() {
    String pkgId = "details?id=" + _activity.getPackageName();
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId));
    goToMarket/*  w w  w .j  ava  2 s  .co m*/
            .addFlags(
                    Intent.FLAG_ACTIVITY_NO_HISTORY
                            | (Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT
                                    : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
                            | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {
        _activity.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        _activity.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/" + pkgId)));
    }
}

From source file:nextinnnovationsoft.com.weightlossrecepies.activity.MainActivity.java

private void openRate() {
    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT
            | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {/*from   w w w  .  j  a v a  2  s . c o m*/
        startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
    }
}

From source file:com.onesignal.GenerateNotification.java

private static Intent getNewBaseDeleteIntent(int notificationId) {
    Intent intent = new Intent(currentContext, notificationOpenedClass)
            .putExtra("notificationId", notificationId).putExtra("dismissed", true);

    if (openerIsBroadcast)
        return intent;
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
            | Intent.FLAG_ACTIVITY_NO_ANIMATION);
}

From source file:com.kaproduction.malibilgiler.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*  ww w.j a va 2  s .com*/
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_detay) {
        // Handle the camera action
        Intent i = new Intent(this, TabbedActivity.class);
        i.putExtra("TAB_ID", 3);
        startActivity(i);
    } else if (id == R.id.nav_vergi) {
        Intent i1 = new Intent(this, TabbedActivity.class);
        i1.putExtra("TAB_ID", 0);
        startActivity(i1);

    } else if (id == R.id.nav_sosyal) {
        Intent i2 = new Intent(this, TabbedActivity.class);
        i2.putExtra("TAB_ID", 1);
        startActivity(i2);

    } else if (id == R.id.nav_makro) {
        Intent i3 = new Intent(this, TabbedActivity.class);
        i3.putExtra("TAB_ID", 2);
        startActivity(i3);

    } else if (id == R.id.nav_gelir) {
        Intent i4 = new Intent(this, CalculateActivity.class);
        i4.putExtra("TAB_ID", 0);
        startActivity(i4);

    } else if (id == R.id.nav_karPayi) {
        Intent i5 = new Intent(this, CalculateActivity.class);
        i5.putExtra("TAB_ID", 1);
        startActivity(i5);

    } else if (id == R.id.nav_agi) {
        Intent i6 = new Intent(this, CalculateActivity.class);
        i6.putExtra("TAB_ID", 2);
        startActivity(i6);

    } else if (id == R.id.nav_asgariUcret) {
        Intent i6 = new Intent(this, CalculateActivity.class);
        i6.putExtra("TAB_ID", 3);
        startActivity(i6);

    } else if (id == R.id.nav_kapiciUcret) {
        Intent i7 = new Intent(this, CalculateActivity.class);
        i7.putExtra("TAB_ID", 4);
        startActivity(i7);

    } else if (id == R.id.nav_gecikmeFaizi) {
        Intent i8 = new Intent(this, CalculateActivity.class);
        i8.putExtra("TAB_ID", 5);
        startActivity(i8);

    } else if (id == R.id.nav_paylas) {
        sendIntent();

    } else if (id == R.id.nav_rating) {
        Uri uri = Uri.parse("market://details?id=" + MainActivity.this.getPackageName());
        Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
        // To count with Play market backstack, After pressing back button,
        // to taken back to our application, we need to add following flags to intent.
        goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT
                | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
        try {
            startActivity(goToMarket);
        } catch (ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                    "http://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName())));
        }
    } else if (id == R.id.nav_hakkinda) {

        showHakkindaDialog();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.userhook.UserHook.java

private static void startActivityToRate() {
    Uri uri = Uri.parse("market://details?id=" + applicationContext.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    if (goToMarket.resolveActivity(applicationContext.getPackageManager()) != null) {
        activityLifecycle.getCurrentActivity().startActivity(goToMarket);
        return;/* w w w .j a  v a  2 s. c  o  m*/
    }

    activityLifecycle.getCurrentActivity().startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://play.google.com/store/apps/details?id=" + applicationContext.getPackageName())));
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public void launchClassZeroActivity(final Context context, final ContentValues messageValues) {
    final Intent classZeroIntent = new Intent(context, ClassZeroActivity.class)
            .putExtra(UI_INTENT_EXTRA_MESSAGE_VALUES, messageValues)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    context.startActivity(classZeroIntent);
}