Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

Introduction

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

Prototype

int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

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

Click Source Link

Usage

From source file:gov.wa.wsdot.android.wsdot.ui.BlogDetailsFragment.java

private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mTitle + " " + mLink);

    return shareIntent;
}

From source file:gov.wa.wsdot.android.wsdot.ui.FacebookDetailsFragment.java

private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mText);

    return shareIntent;
}

From source file:com.paranoid.gerrit.adapters.ChangeListAdapter.java

@Override
public void bindView(View view, Context context, final Cursor cursor) {

    setIndicies(cursor);//  w w  w  . j a v  a2  s  .  c o m

    ViewHolder viewHolder = (ViewHolder) view.getTag();
    if (viewHolder == null) {
        viewHolder = new ViewHolder(view);
    }

    viewHolder.changeid = cursor.getString(changeid_index);
    viewHolder.changeStatus = cursor.getString(status_index);
    viewHolder.webAddress = getWebAddress(cursor.getInt(changenum_index));
    view.setTag(viewHolder);

    if (viewHolder.changeid.equals(selectedChangeId)) {
        CommitCard commitCard = (CommitCard) view;
        commitCard.setChangeSelected(true);
        selectedChangeView = commitCard;
    } else {
        ((CommitCard) view).setChangeSelected(false);
    }

    View.OnClickListener cardListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewHolder vh = (ViewHolder) view.getTag();
            Intent intent = new Intent(PatchSetViewerFragment.NEW_CHANGE_SELECTED);
            intent.putExtra(PatchSetViewerFragment.CHANGE_ID, vh.changeid);
            intent.putExtra(PatchSetViewerFragment.STATUS, vh.changeStatus);
            intent.putExtra(PatchSetViewerFragment.EXPAND_TAG, true);
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);

            // Set this view as selected
            setSelectedChangeId((CommitCard) view, vh.changeid);
        }
    };

    // Root view already has viewHolder tagged
    view.setOnClickListener(cardListener);

    viewHolder.shareView.setTag(viewHolder);
    viewHolder.shareView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewHolder vh = (ViewHolder) view.getTag();
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            intent.putExtra(Intent.EXTRA_SUBJECT, String.format(
                    mContext.getResources().getString(R.string.commit_shared_from_mgerrit), vh.changeid));
            intent.putExtra(Intent.EXTRA_TEXT, vh.webAddress + " #mGerrit");
            mContext.startActivity(intent);
        }
    });

    viewHolder.browserView.setTag(viewHolder);
    viewHolder.browserView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String webAddr = ((ViewHolder) view.getTag()).webAddress;
            if (webAddr != null) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webAddr));
                mContext.startActivity(browserIntent);
            } else {
                Toast.makeText(view.getContext(), R.string.failed_to_find_url, Toast.LENGTH_SHORT).show();
            }
        }
    });

    super.bindView(view, context, cursor);
}

From source file:gov.wa.wsdot.android.wsdot.ui.NewsDetailsFragment.java

private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, mTitle);
    shareIntent.putExtra(Intent.EXTRA_TEXT, mDescription + " " + mLink);

    return shareIntent;
}

From source file:com.licubeclub.zionhs.PostViewActivity.java

private Intent createShareIntent() {
    //? ACTION_SEND  .
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    //Flag   ?.   ?   ? ? Activity  ,
    // ? ? Activity    ?
    //FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET  ?.
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    // ? .  ? ./*w  w  w .  j av  a  2 s  . co  m*/
    shareIntent.setType("text/plain");

    // ?? Extra  ?.
    shareIntent.putExtra(Intent.EXTRA_TEXT, URL);
    return shareIntent;
}

From source file:com.jeffgodwyll.android.qod.app.DetailFragment.java

private Intent createShareForecastIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mForecast + SHARE_HASHTAG);
    return shareIntent;
}

From source file:com.qrcode.app.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }/*ww  w  .j  ava 2s.co  m*/
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//??????????

        try {
            activity.handleDecode((Result) message.obj, barcode);//???????        /***********************************************************************/
        } catch (JSONException e) {
            e.printStackTrace();
        }
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:com.owncloud.android.ui.dialog.RateMeDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Create a view by inflating desired layout
    View v = inflater.inflate(R.layout.rate_me_dialog, container, false);

    Button rateNowButton = v.findViewById(R.id.button_rate_now);
    Button laterButton = v.findViewById(R.id.button_later);
    Button noThanksButton = v.findViewById(R.id.button_no_thanks);
    TextView titleView = v.findViewById(R.id.rate_me_dialog_title_view);

    titleView.setText(String.format(getString(R.string.rate_dialog_title), getString(R.string.app_name)));

    rateNowButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w w  w.  j ava 2s .  c om*/
        public void onClick(View v) {
            String packageName = getArguments().getString(APP_PACKAGE_NAME);
            Uri uri = Uri.parse(MARKET_DETAILS_URI + packageName);
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);

            /// 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 >= Build.VERSION_CODES.LOLLIPOP) {
                flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
            } else {
                flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
            }
            goToMarket.addFlags(flags);

            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                getActivity()
                        .startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_URI + packageName)));
            }
            dialog.dismiss();
        }
    });

    laterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences preferences = getActivity().getSharedPreferences(AppRater.APP_RATER_PREF_TITLE,
                    0);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putLong(AppRater.APP_RATER_PREF_DATE_NEUTRAL, System.currentTimeMillis());
            editor.apply();
            dialog.dismiss();
        }
    });

    noThanksButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences preferences = getActivity().getSharedPreferences(AppRater.APP_RATER_PREF_TITLE,
                    0);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putBoolean(AppRater.APP_RATER_PREF_DONT_SHOW, true);
            editor.apply();
            dialog.dismiss();
        }
    });

    return v;
}

From source file:com.onebus.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }//from   w w  w  .  j  a v  a 2 s. co m
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//

        try {
            activity.handleDecode((Result) message.obj, barcode);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } //?        /***********************************************************************/
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:com.udacity.android.student.project.app.CourseFragment.java

private Intent createShareCourseIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, shareIntentText + COURSE_SHARE_HASHTAG);
    return shareIntent;
}