Example usage for android.content Intent setFlags

List of usage examples for android.content Intent setFlags

Introduction

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

Prototype

public @NonNull Intent setFlags(@Flags int flags) 

Source Link

Document

Set special flags controlling how this intent is handled.

Usage

From source file:com.kogitune.wearlocationwatchface.WatchFaceService.java

public void startRefresh() {
    floatingActionBarManager.startRefresh();
    GoogleApiClientObservable.connection(this).flatMap(GoogleApiClientObservable::location).map(location -> {
        int range = new WearSharedPreference(this).get(getString(R.string.key_preference_search_range),
                getResources().getInteger(R.integer.search_range_default));
        return "https://api.flickr.com/services/rest/?method=flickr.photos.search&group_id=1463451@N25&api_key="
                + BuildConfig.FLICKR_API_KEY + "&license=1%2C2%2C3%2C4%2C5%2C6&lat=" + location.getLatitude()
                + "&lon=" + location.getLongitude() + "&radius=" + range
                + "&extras=url_n,url_l&per_page=30&format=json&nojsoncallback=1";
    }).flatMap(url -> GoogleApiClientObservable.fetchText(this, url)).timeout(50, TimeUnit.SECONDS)
            .observeOn(mainThread()).subscribeOn(Schedulers.io()).subscribe(this::applyView, e -> {
                if (e instanceof LocationNotAvailableException) {
                    try {
                        final Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(intent);
                        return;
                    } catch (final ActivityNotFoundException e1) {
                    }//  w ww  .j  a va 2s  .com
                }
                floatingActionBarManager.stopRefresh();
                Toast.makeText(WatchFaceService.this, "Can't get photo in time.", Toast.LENGTH_SHORT);
                e.printStackTrace();
            });
}

From source file:com.molice.oneingdufs.androidpn.Notifier.java

public void notify(String notificationId, String apiKey, String title, String message, String uri) {
    Log.d(LOGTAG, "notify()...");

    Log.d(LOGTAG, "notificationId=" + notificationId);
    Log.d(LOGTAG, "notificationApiKey=" + apiKey);
    Log.d(LOGTAG, "notificationTitle=" + title);
    Log.d(LOGTAG, "notificationMessage=" + message);
    Log.d(LOGTAG, "notificationUri=" + uri);

    if (SettingsActivity.getNotificationEnabled(context)) {
        // Show the toast
        //            if (isNotificationToastEnabled()) {
        //                Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        //            }

        // Notification
        Notification notification = new Notification();
        notification.icon = getNotificationIcon();
        //            notification.defaults = Notification.DEFAULT_LIGHTS;
        if (SettingsActivity.getNotificationSound(context)) {
            notification.defaults |= Notification.DEFAULT_SOUND;
        }/*from w  w  w. j a  v  a  2 s.co  m*/
        if (SettingsActivity.getNotificationVibrate(context)) {
            notification.defaults |= Notification.DEFAULT_VIBRATE;
        }
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notification.when = System.currentTimeMillis();
        notification.tickerText = message;

        //            Intent intent;
        //            if (uri != null
        //                    && uri.length() > 0
        //                    && (uri.startsWith("http:") || uri.startsWith("https:")
        //                            || uri.startsWith("tel:") || uri.startsWith("geo:"))) {
        //                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        //            } else {
        //                String callbackActivityPackageName = sharedPrefs.getString(
        //                        Constants.CALLBACK_ACTIVITY_PACKAGE_NAME, "");
        //                String callbackActivityClassName = sharedPrefs.getString(
        //                        Constants.CALLBACK_ACTIVITY_CLASS_NAME, "");
        //                intent = new Intent().setClassName(callbackActivityPackageName,
        //                        callbackActivityClassName);
        //                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //                intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        //            }

        Intent intent = new Intent(context, MessageDetailActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        JSONObject data = formatMetaFromTitle(title);
        try {
            data.putOpt("id", notificationId);
            data.putOpt("content", message);
        } catch (Exception e) {
            Log.d("JSON", "Notifier#notify, e=" + e.toString());
        }
        intent.putExtra("data", data.toString());
        intent.putExtra("fromNotification", true);
        //            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        //            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        //            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        //            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent contentIntent = PendingIntent.getActivity(context, random.nextInt(), intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        notification.setLatestEventInfo(context, data.optString("title"), message, contentIntent);
        notificationManager.notify(random.nextInt(), notification);

        //            Intent clickIntent = new Intent(
        //                    Constants.ACTION_NOTIFICATION_CLICKED);
        //            clickIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        //            clickIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        //            clickIntent.putExtra(Constants.NOTIFICATION_TITLE, title);
        //            clickIntent.putExtra(Constants.NOTIFICATION_MESSAGE, message);
        //            clickIntent.putExtra(Constants.NOTIFICATION_URI, uri);
        //            //        positiveIntent.setData(Uri.parse((new StringBuilder(
        //            //                "notif://notification.adroidpn.org/")).append(apiKey).append(
        //            //                "/").append(System.currentTimeMillis()).toString()));
        //            PendingIntent clickPendingIntent = PendingIntent.getBroadcast(
        //                    context, 0, clickIntent, 0);
        //
        //            notification.setLatestEventInfo(context, title, message,
        //                    clickPendingIntent);
        //
        //            Intent clearIntent = new Intent(
        //                    Constants.ACTION_NOTIFICATION_CLEARED);
        //            clearIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        //            clearIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        //            //        negativeIntent.setData(Uri.parse((new StringBuilder(
        //            //                "notif://notification.adroidpn.org/")).append(apiKey).append(
        //            //                "/").append(System.currentTimeMillis()).toString()));
        //            PendingIntent clearPendingIntent = PendingIntent.getBroadcast(
        //                    context, 0, clearIntent, 0);
        //            notification.deleteIntent = clearPendingIntent;
        //
        //            notificationManager.notify(random.nextInt(), notification);

    } else {
        Log.w(LOGTAG, "Notificaitons disabled.");
    }
}

From source file:com.github.notizklotz.derbunddownloader.issuesgrid.DownloadedIssuesActivity.java

private void openPDF(String uri) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(uri)), MEDIA_TYPE_PDF);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

    PackageManager packageManager = getPackageManager();
    assert packageManager != null;

    if (intent.resolveActivity(packageManager) != null) {
        startActivity(intent);/*w  w w .j av  a 2s  .  c o m*/
    } else {
        Toast.makeText(this, R.string.no_pdf_reader, Toast.LENGTH_LONG).show();
    }
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateTo(final Class<? extends Activity> activityClass, final int flags) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);

    startActivity(intent);// w ww.  j  a  v a 2s .c  om
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateTo(final Class<? extends Activity> activityClass, final int flags, final Bundle bundle) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);
    intent.putExtras(bundle);/*from www.  j  a va  2  s  .  c  o  m*/

    startActivity(intent);
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateForResult(final Class<? extends Activity> activityClass, final int requestCode,
        final int flags) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);

    startActivityForResult(intent, requestCode);
}

From source file:com.teleca.jamendo.activity.PlayerActivity.java

/**
 * Launch this Activity from the outside, with defined playlist
 *
 * @param c context from which Activity should be started
 * @param a playlist to be played/*from w ww  . java 2  s .  c  o  m*/
 */
public static void launch(Context c, Playlist playlist) {
    Intent intent = new Intent(c, PlayerActivity.class);
    intent.putExtra("playlist", playlist);

    /*
     * For example, consider a task consisting of the activities: 
     * A, B, C, D. If D calls startActivity() with an Intent that
     * resolves to the component of activity B, then C and D will
     * be finished and B receive the given Intent, resulting in 
     * the stack now being: A, B. 
     */
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    c.startActivity(intent);
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateForResult(final Class<? extends Activity> activityClass, final int requestCode,
        final int flags, final Bundle bundle) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);
    intent.putExtras(bundle);//from w  w  w  .  j  a  v  a2  s  .  c o  m

    startActivityForResult(intent, requestCode);
}

From source file:com.aokyu.dev.pocket.PocketClient.java

private void continueAuthorization(Activity callback, RequestToken requestToken) {
    String url = PocketServer.getRedirectUrl(mConsumerKey, requestToken);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    callback.startActivity(intent);/* w w w  . j a  va 2s .c  o  m*/
}

From source file:com.irontec.fragments.EzarpenakFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setHasOptionsMenu(true);/* w w w .j av a2s.c o m*/

    mContext = getActivity().getBaseContext();

    View rootView = inflater.inflate(R.layout.fragment_ezarpenak, container, false);
    mViewSwitcher = (ViewSwitcher) rootView.findViewById(R.id.viewSwitcher1);
    mEzarpenZerrenda = (ListView) rootView.findViewById(R.id.ezarpenak_list);

    mItems = new ArrayList<BasicNameValuePair>();

    BasicNameValuePair item1 = new BasicNameValuePair("Saioa itxi", "");
    BasicNameValuePair item2 = new BasicNameValuePair("Sare sozialak", "Zure sare sozialak kudeatu");
    BasicNameValuePair item3 = new BasicNameValuePair("Lizentziak", "Erabilitako baliabideak");
    BasicNameValuePair item4 = new BasicNameValuePair("Honi buruz", "");

    mItems.add(item1);
    mItems.add(item2);
    mItems.add(item3);
    mItems.add(item4);

    mEzarpenZerrenda.setAdapter(new SimpleLicenseAdapter(mContext, mItems));
    mEzarpenZerrenda.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            Intent intent = null;
            if (position == 0) {
                MintzatuAPI.logout(mContext);
                intent = new Intent(getActivity().getBaseContext(), LoginCircles.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                if (getActivity() != null) {
                    getActivity().finish();
                }
            } else if (position == 3) {
                intent = new Intent(mContext, HoniBuruzActivity.class);
            } else {
                intent = new Intent(mContext, EzarpenakDetailActivity.class);
            }

            switch (position) {
            case 1:
                intent.putExtra("detail_type", 0);
                break;
            case 2:
                intent.putExtra("detail_type", 1);
                break;
            default:
                break;
            }

            if (intent != null) {
                startActivity(intent);
            }
        }
    });

    mViewSwitcher.showNext();

    return rootView;
}