Example usage for android.content Intent FLAG_ACTIVITY_NEW_DOCUMENT

List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_DOCUMENT

Introduction

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

Prototype

int FLAG_ACTIVITY_NEW_DOCUMENT

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

Click Source Link

Document

This flag is used to open a document into a new task rooted at the activity launched by this Intent.

Usage

From source file:com.hacktx.android.activities.MainActivity.java

private void setupAppShortcuts() {
    // Setup app shortcuts
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1
            && mConfigManager.getValue(ConfigParam.CHECK_IN)) {
        ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

        Intent checkInIntent = new Intent(Intent.ACTION_VIEW);
        checkInIntent.setPackage("com.hacktx.android");
        checkInIntent.setClass(this, CheckInActivity.class);
        checkInIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY
                | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        checkInIntent.putExtra("fromShortcut", true);

        ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "check-in")
                .setShortLabel(getString(R.string.app_shortcut_check_in))
                .setLongLabel(getString(R.string.app_shortcut_check_in))
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher)).setIntent(checkInIntent).build();

        shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
    }/*from w  ww. ja v  a2 s  .co m*/
}

From source file:barqsoft.footballscores.Fragments.DetailFragment.java

public Intent createShareForecastIntent(String ShareText) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, ShareText + getString(R.string.football_scores_hashtag));
    return shareIntent;
}

From source file:org.kontalk.util.SystemUtils.java

public static Intent externalIntent(String action, Uri data) {
    Intent i = new Intent(action, data);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    } else {//w  ww . jav  a  2s . co m
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    }
    return i;
}

From source file:com.android.deskclock.stopwatch.StopwatchFragment.java

/**
 * Send stopwatch time and lap times to an external sharing application.
 *//* w  w  w  .  j  av a2  s  . c o m*/
private void doShare() {
    final String[] subjects = getResources().getStringArray(R.array.sw_share_strings);
    final String subject = subjects[(int) (Math.random() * subjects.length)];
    final String text = mLapsAdapter.getShareText();

    @SuppressLint("InlinedApi")
    @SuppressWarnings("deprecation")
    final Intent shareIntent = new Intent(Intent.ACTION_SEND)
            .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT
                    : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain");

    final Context context = getActivity();
    final String title = context.getString(R.string.sw_share_button);
    final Intent shareChooserIntent = Intent.createChooser(shareIntent, title);
    try {
        context.startActivity(shareChooserIntent);
    } catch (ActivityNotFoundException anfe) {
        LogUtils.e("No compatible receiver is found");
    }
}

From source file:com.stillnojetpacks.huffr.activities.MainActivity.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Intent rateIntentForUrl(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW, uriForUrl(url));
    int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
    } else {//from www.ja va  2  s . co m
        flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
    }
    intent.addFlags(flags);
    return intent;
}

From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java

/**
 * Send stopwatch time and lap times to an external sharing application.
 *///from  w  w  w.  java2 s . com
private void doShare() {
    // Disable the fab buttons to avoid double-taps on the share button.
    updateFab(BUTTONS_DISABLE);

    final String[] subjects = getResources().getStringArray(R.array.sw_share_strings);
    final String subject = subjects[(int) (Math.random() * subjects.length)];
    final String text = mLapsAdapter.getShareText();

    @SuppressLint("InlinedApi")
    @SuppressWarnings("deprecation")
    final Intent shareIntent = new Intent(Intent.ACTION_SEND)
            .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT
                    : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain");

    final Context context = getActivity();
    final String title = context.getString(R.string.sw_share_button);
    final Intent shareChooserIntent = Intent.createChooser(shareIntent, title);
    try {
        context.startActivity(shareChooserIntent);
    } catch (ActivityNotFoundException anfe) {
        LogUtils.e("Cannot share lap data because no suitable receiving Activity exists");
        updateFab(BUTTONS_IMMEDIATE);
    }
}

From source file:com.android.mail.browse.MessageAttachmentBar.java

private void previewAttachment() {
    if (mAttachment.canPreview()) {
        final Intent previewIntent = new Intent(Intent.ACTION_VIEW, mAttachment.previewIntentUri);
        previewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        getContext().startActivity(previewIntent);

        Analytics.getInstance().sendEvent("preview_attachment",
                Utils.normalizeMimeType(mAttachment.getContentType()), null, mAttachment.size);
    }//from  w w w.j  a v a  2 s  . c om
}

From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java

/**
 * Send stopwatch time and lap times to an external sharing application.
 *///from   www  .j av a 2  s  .  c  o  m
private void doShare() {
    final String[] subjects = getResources().getStringArray(com.wizardsofm.deskclock.R.array.sw_share_strings);
    final String subject = subjects[(int) (Math.random() * subjects.length)];
    final String text = mLapsAdapter.getShareText();

    @SuppressLint("InlinedApi")
    @SuppressWarnings("deprecation")
    final Intent shareIntent = new Intent(Intent.ACTION_SEND)
            .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT
                    : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain");

    final Context context = getActivity();
    final String title = context.getString(com.wizardsofm.deskclock.R.string.sw_share_button);
    final Intent shareChooserIntent = Intent.createChooser(shareIntent, title);
    try {
        context.startActivity(shareChooserIntent);
    } catch (ActivityNotFoundException anfe) {
        LogUtils.e("No compatible receiver is found");
    }
}

From source file:io.github.hidroh.materialistic.AppUtils.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void openPlayStore(Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_URL));
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    } else {//from  ww w. j a v a2 s .  c om
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    }
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(context, R.string.no_playstore, Toast.LENGTH_SHORT).show();
    }
}

From source file:android.support.v7.widget.ShareActionProvider.java

private void updateIntent(Intent intent) {
    if (Build.VERSION.SDK_INT >= 21) {
        // If we're on Lollipop, we can open the intent as a document
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    } else {//from   w  ww.  j a  va 2 s. c  o m
        // Else, we will use the old CLEAR_WHEN_TASK_RESET flag
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    }
}