Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

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

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:cw.kop.autobackground.files.DownloadThread.java

private void finish() {
    if (AppSettings.useDownloadNotification()) {
        Notification.Builder notifyComplete = new Notification.Builder(appContext)
                .setContentTitle("Download Completed")
                .setContentText("AutoBackground downloaded " + totalDownloaded + " images")
                .setSmallIcon(R.drawable.ic_photo_white_24dp);

        Notification notification;

        if (Build.VERSION.SDK_INT >= 16) {
            notifyComplete.setPriority(Notification.PRIORITY_LOW);
            Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
            inboxStyle.setBigContentTitle("Downloaded Image Details:");

            inboxStyle.addLine("Total images enabled: " + FileHandler.getBitmapList().size());

            for (String detail : imageDetails.split(AppSettings.DATA_SPLITTER)) {
                inboxStyle.addLine(detail);
            }//from w  w w  . ja v a 2 s  . c o  m

            notifyComplete.setStyle(inboxStyle);
            notification = notifyComplete.build();
        } else {
            notification = notifyComplete.getNotification();
        }

        notificationManager.cancel(NOTIFICATION_ID);
        notificationManager.notify(NOTIFICATION_ID, notification);
    }

    Intent cycleIntent = new Intent();
    cycleIntent.setAction(LiveWallpaperService.CYCLE_IMAGE);
    cycleIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    appContext.sendBroadcast(cycleIntent);

    Intent resetDownloadIntent = new Intent(FileHandler.DOWNLOAD_TERMINATED);
    LocalBroadcastManager.getInstance(appContext).sendBroadcast(resetDownloadIntent);

    Intent intent = new Intent();
    intent.setAction(LiveWallpaperService.UPDATE_NOTIFICATION);
    intent.putExtra("use", AppSettings.useNotification());
    appContext.sendBroadcast(intent);

    AppSettings.checkUsedLinksSize();
    appContext = null;

    Log.i(TAG, "Download Finished");
    FileHandler.setIsDownloading(false);
}

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection
    final Activity activity = getActivity();
    switch (item.getItemId()) {
    case R.id.action_download:
        Toast.makeText(activity,//from ww w. j a v  a 2 s .c  o  m
                String.format(getActivity().getResources().getString(R.string.toast_downloading), urls.size()),
                Toast.LENGTH_SHORT).show();
        Intent serviceIntent = new Intent(activity, DownloadService.class);
        serviceIntent.putParcelableArrayListExtra("ids", ids);
        if (albumId != null)
            serviceIntent.putExtra("albumName", albumId);
        else
            serviceIntent.putExtra("albumName", imageCall);
        activity.startService(serviceIntent);
        return true;
    case R.id.action_refresh:
        urls = new ArrayList<String>();
        ids = new ArrayList<JSONParcelable>();
        page = 0;
        makeGallery();
        return true;
    case R.id.action_copy:
        ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("imgur Link", "http://imgur.com/a/" + albumId);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(activity, R.string.toast_copied, Toast.LENGTH_SHORT).show();
        return true;
    case R.id.action_share:
        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intent.EXTRA_TEXT, "http://imgur.com/a/" + albumId);
        startActivity(intent);
        return true;
    case R.id.action_new:
        Intent i = new Intent(this.getActivity().getApplicationContext(), ImageSelectActivity.class);
        startActivityForResult(i, 1);
        //select image
        return true;
    case R.id.action_comments:
        if (galleryAlbumData != null) {
            CommentsAsync commentsAsync = new CommentsAsync(((ImgurHoloActivity) getActivity()),
                    galleryAlbumData);
            commentsAsync.execute();
            return true;
        } else
            return super.onOptionsItemSelected(item);
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.raceyourself.android.samsung.ProviderService.java

private void popupGpsDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("RaceYourself works best with GPS.\n\nWould you like to enable your GPS now?")
            .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(@SuppressWarnings("unused") final DialogInterface dialog,
                        @SuppressWarnings("unused") final int id) {
                    Intent gps = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    gps.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(gps);//from   w  w  w.  j  a va  2  s. com
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
                    dialog.cancel();
                }
            }).setTitle("RaceYourself Gear Edition");
    alert = builder.create();
    alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    alert.show();
}

From source file:com.example.jkgan.pmot.service.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./* w  w w . j a  va 2s  .co  m*/
 */
private void sendNotification(final String message, final String title, String id) {

    String url = MyApplication.getApiUrl() + "/promotions/" + id + "?token="
            + MyApplication.getUser().getToken();
    final Promotion[] promotion = { null };

    final OkHttpClient client = new OkHttpClient();

    final Request request = new Request.Builder().url(url).build();

    //        new Thread(new Runnable() {
    //            @Override
    //            public void run() {
    Response response = null;
    try {
        response = client.newCall(request).execute();
        JSONObject jsnObj2 = new JSONObject(response.body().string());

        promotion[0] = new Promotion(jsnObj2.optString("pName"), jsnObj2.optString("description"),
                jsnObj2.optString("id"),
                jsnObj2.getJSONObject("image").getJSONObject("medium").optString("url"),
                jsnObj2.getJSONObject("image").getJSONObject("small").optString("url"),
                jsnObj2.optString("term_and_condition"), jsnObj2.optString("name"),
                jsnObj2.optString("address"), jsnObj2.optString("sId"), getDate(jsnObj2.optString("starts_at")),
                getDate(jsnObj2.optString("expires_at")), jsnObj2.optString("phone"));

        Intent intent = new Intent(getApplicationContext(), PromotionActivity.class);
        intent.putExtra("NAME", promotion[0].getName());
        intent.putExtra("SHOP_ID", promotion[0].getId());
        intent.putExtra("IMAGE", promotion[0].getImage());
        intent.putExtra("DESCRIPTION", promotion[0].getDescription());
        intent.putExtra("TNC", promotion[0].getTnc());
        intent.putExtra("SHOP_NAME", promotion[0].getShop().getName());
        intent.putExtra("ADDRESS", promotion[0].getShop().getAddress());
        intent.putExtra("START", promotion[0].getStarts_at());
        intent.putExtra("EXPIRE", promotion[0].getExpires_at());
        intent.putExtra("PHONE", promotion[0].getShop().getPhone());
        intent.putExtra("SUBSCRIBED", true);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */,
                intent, PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        if (numMessages >= 1) {
            notificationTitle += (", " + title);

            notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
                    .setSmallIcon(R.mipmap.ic_launcher).setContentTitle((numMessages + 1) + " new promotions")
                    .setContentText(notificationTitle).setAutoCancel(true).setSound(defaultSoundUri)
                    .setContentIntent(pendingIntent);
            numMessages = 0;

            notificationBuilder.setContentText(message).setNumber(++numMessages);

        } else {
            notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
                    .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(message)
                    .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

            notificationTitle = title;
            numMessages++;
            //            notificationBuilder.setContentText(message)
            //                    .setNumber(++numMessages);
        }

        NotificationManager notificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);

        // On gnre un nombre alatoire pour pouvoir afficher plusieurs notifications
        notificationManager.notify(notifyID, notificationBuilder.build());
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.wojtechnology.sunami.TheBrain.java

private void setNotification(FireMixtape song) {
    if (mPlaying == null) {
        stopForeground(true);// www . j av  a2s  .  c  o m
        return;
    }
    setMetadata(song);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Notification is created in setMetadata
        return;
    }

    if (mNotification == null || mNotificationView == null) {
        Intent notificationIntent = new Intent(this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, notificationIntent, 0);

        mNotificationView = new RemoteViews(getPackageName(), R.layout.notification);

        mNotification = new Notification.Builder(this).setSmallIcon(R.mipmap.sunaminotif)
                .setContentIntent(pendingIntent).setContent(mNotificationView).build();
    }

    Intent servicePlayIntent = new Intent(getApplicationContext(), TheBrain.class);
    servicePlayIntent.setAction(TheBrain.TOGGLE_PLAY);
    servicePlayIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingPlayIntent = PendingIntent.getService(mContext, 1, servicePlayIntent, 0);
    Intent serviceNextIntent = new Intent(getApplicationContext(), TheBrain.class);
    serviceNextIntent.setAction(TheBrain.PLAY_NEXT);
    serviceNextIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingNextIntent = PendingIntent.getService(mContext, 1, serviceNextIntent, 0);
    Intent serviceStopIntent = new Intent(getApplicationContext(), TheBrain.class);
    serviceStopIntent.setAction(TheBrain.PLAY_STOP);
    serviceStopIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingStopIntent = PendingIntent.getService(mContext, 1, serviceStopIntent, 0);

    mNotificationView.setTextViewText(R.id.notif_title, song.title);
    mNotificationView.setTextViewText(R.id.notif_artist, song.artist);
    mNotificationView.setOnClickPendingIntent(R.id.play_notif_button, pendingPlayIntent);
    mNotificationView.setOnClickPendingIntent(R.id.next_notif_button, pendingNextIntent);
    mNotificationView.setOnClickPendingIntent(R.id.close_notif_button, pendingStopIntent);

    setNotificationStatus(true);
}

From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java

void init() {

    //        img=(ImageView)findViewById(R.id.logo);

    TextView build = (TextView) findViewById(R.id.checkfornew);
    build.setOnClickListener(new View.OnClickListener() {
        @Override//from  w ww . j av  a 2 s. c om
        public void onClick(View v) {
            if (android.os.Build.VERSION.SDK_INT > 9) {
                StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                StrictMode.setThreadPolicy(policy);
            }

            CommonUtilities.logMe("about to check for version ");
            try {
                WebServiceHandler wsb = new WebServiceHandler();
                ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
                String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php",
                        postParameters);
                JSONObject jsonObject = new JSONObject(result);
                String version = jsonObject.getString("version");
                String features = jsonObject.getString("features");
                System.err.println("version is : " + version);
                if (!LoginActivity.myversion.equals(version)) {
                    MyToast.popmessagelong(
                            "There is a new build available. Please download for these features: " + features,
                            TabsActivity.this);
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp"));
                    browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(browserIntent);
                } else {
                    MyToast.popmessagelong("You have the most current version!", TabsActivity.this);
                }
            } catch (Exception exc) {
                exc.printStackTrace();
            }

        }
    });

    TextView maillog = (TextView) findViewById(R.id.maillog);
    maillog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final Dialog dialog = new Dialog(TabsActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_logout);

            TextView question = (TextView) dialog.findViewById(R.id.question);
            question.setText("Are you sure you want to email the log?");
            TextView extra = (TextView) dialog.findViewById(R.id.extratext);
            extra.setText("");

            dialog.getWindow().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            Button yes = (Button) dialog.findViewById(R.id.yesbtn);
            yes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent i = new Intent(Intent.ACTION_SEND);
                    i.setType("message/rfc822");
                    i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" });
                    i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log");
                    i.putExtra(Intent.EXTRA_TEXT, "body of email");
                    try {
                        startActivity(Intent.createChooser(i, "Send mail..."));
                    } catch (android.content.ActivityNotFoundException ex) {
                        Toast.makeText(TabsActivity.this, "There are no email clients installed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    finish();
                }
            });
            Button no = (Button) dialog.findViewById(R.id.nobtn);
            no.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            ImageView close = (ImageView) dialog.findViewById(R.id.ivClose);
            close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            dialog.show();

        }
    });

    listops listops = new listops(TabsActivity.this);
    CommonUtilities.logMe("logging in as: " + listops.getString("firstname"));
    TextView name = (TextView) findViewById(R.id.welcome);
    name.setText("Welcome, " + listops.getString("firstname"));

    TextView logoutname = (TextView) findViewById(R.id.logoutname);
    logoutname.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(TabsActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_logout);
            dialog.getWindow().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.transparent)));
            dialog.setContentView(R.layout.dialog_logout);
            Button yes = (Button) dialog.findViewById(R.id.yesbtn);
            yes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    MyToast.popmessagelong("Logging out... ", TabsActivity.this);
                    SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putString(Constants.loginkey, "");
                    editor.commit();
                    listops listops = new listops(TabsActivity.this);
                    //make sure to remove the downloaded schools

                    Intent intent = new Intent(TabsActivity.this, LoginActivity.class);
                    startActivity(intent);
                    ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>();
                    listops.putdrilllist(ls);
                    listops.putservicelist(ls);
                    listops.putinstallllist(ls);
                    ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>();
                    listops.putpendinglist(l);

                    finish();
                }
            });
            Button no = (Button) dialog.findViewById(R.id.nobtn);
            no.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            ImageView close = (ImageView) dialog.findViewById(R.id.ivClose);
            close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            dialog.show();
        }

    });

    ll1 = (LinearLayout) findViewById(R.id.ll1);
    ll2 = (LinearLayout) findViewById(R.id.ll2);
    ll3 = (LinearLayout) findViewById(R.id.ll3);
    ll4 = (LinearLayout) findViewById(R.id.ll4);
    ll5 = (LinearLayout) findViewById(R.id.ll5);
    ll6 = (LinearLayout) findViewById(R.id.ll6);
    ll1.setBackgroundColor(getResources().getColor(R.color.White));

    llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool);
    llDrills = (LinearLayout) findViewById(R.id.llDrills);
    llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls);
    llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls);
    llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads);

    frameLayout = (FrameLayout) findViewById(R.id.frame);

}

From source file:fr.cph.chicago.core.activity.BusBoundActivity.java

@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.checkBusData(this);
    if (!this.isFinishing()) {
        setContentView(R.layout.activity_bus_bound);
        ButterKnife.bind(this);

        if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) {
            final Bundle extras = getIntent().getExtras();
            busRouteId = extras.getString(bundleBusRouteId);
            busRouteName = extras.getString(bundleBusRouteName);
            bound = extras.getString(bundleBusBound);
            boundTitle = extras.getString(bundleBusBoundTitle);
        }//  w  w w. j a v a2  s  .c om
        busBoundAdapter = new BusBoundAdapter();
        setListAdapter(busBoundAdapter);
        getListView().setOnItemClickListener((adapterView, view, position, id) -> {
            final BusStop busStop = (BusStop) busBoundAdapter.getItem(position);
            final Intent intent = new Intent(getApplicationContext(), BusActivity.class);

            final Bundle extras = new Bundle();
            extras.putInt(bundleBusStopId, busStop.getId());
            extras.putString(bundleBusStopName, busStop.getName());
            extras.putString(bundleBusRouteId, busRouteId);
            extras.putString(bundleBusRouteName, busRouteName);
            extras.putString(bundleBusBound, bound);
            extras.putString(bundleBusBoundTitle, boundTitle);
            extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude());
            extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude());

            intent.putExtras(extras);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        });

        filter.addTextChangedListener(new TextWatcher() {
            private List<BusStop> busStopsFiltered;

            @Override
            public void beforeTextChanged(final CharSequence s, final int start, final int count,
                    final int after) {
                busStopsFiltered = new ArrayList<>();
            }

            @Override
            public void onTextChanged(final CharSequence s, final int start, final int before,
                    final int count) {
                if (busStops != null) {
                    Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s))
                            .forEach(busStopsFiltered::add);
                }
            }

            @Override
            public void afterTextChanged(final Editable s) {
                busBoundAdapter.update(busStopsFiltered);
                busBoundAdapter.notifyDataSetChanged();
            }
        });

        Util.setWindowsColor(this, toolbar, TrainLine.NA);
        toolbar.setTitle(busRouteId + " - " + boundTitle);

        toolbar.setNavigationIcon(arrowBackWhite);
        toolbar.setOnClickListener(v -> finish());

        ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound)
                .subscribe(onNext -> {
                    busStops = onNext;
                    busBoundAdapter.update(onNext);
                    busBoundAdapter.notifyDataSetChanged();
                }, onError -> {
                    Log.e(TAG, onError.getMessage(), onError);
                    Util.showOopsSomethingWentWrong(getListView());
                });

        Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus,
                BUSES_STOP_URL, 0);

        // Preventing keyboard from moving background when showing up
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }
}

From source file:com.frostwire.android.gui.activities.MainActivity.java

private void openTorrentUrl(Intent intent) {
    try {// ww w  . j av a  2  s  . co  m
        //Open a Torrent from a URL or from a local file :), say from Astro File Manager.
        //Show me the transfer tab
        Intent i = new Intent(this, MainActivity.class);
        i.setAction(Constants.ACTION_SHOW_TRANSFERS);
        i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(i);
        //go!
        final String uri = intent.getDataString();
        intent.setAction(null);
        if (uri != null) {
            if (uri.startsWith("file") || uri.startsWith("http") || uri.startsWith("https")
                    || uri.startsWith("magnet")) {
                TransferManager.instance().downloadTorrent(uri,
                        new HandpickedTorrentDownloadDialogOnFetch(this));
            } else if (uri.startsWith("content")) {
                String newUri = saveViewContent(this, Uri.parse(uri), "content-intent.torrent");
                if (newUri != null) {
                    TransferManager.instance().downloadTorrent(newUri,
                            new HandpickedTorrentDownloadDialogOnFetch(this));
                }
            }
        } else {
            LOG.warn(
                    "MainActivity.onNewIntent(): Couldn't start torrent download from Intent's URI, intent.getDataString() -> null");
            LOG.warn("(maybe URI is coming in another property of the intent object - #fragmentation)");
        }
    } catch (Throwable e) {
        LOG.error("Error opening torrent from intent", e);
    }
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java

private void onUnhandled(Context context, Intent intent) {
    String action = intent.getAction();
    if ((MFPPushUtils.getIntentPrefix(context) + GCM_MESSAGE).equals(action)) {
        MFPInternalPushMessage message = intent.getParcelableExtra(GCM_EXTRA_MESSAGE);

        int notificationId = randomObj.nextInt();
        message.setNotificationId(notificationId);
        saveInSharedPreferences(message);

        intent = new Intent(MFPPushUtils.getIntentPrefix(context) + IBM_PUSH_NOTIFICATION);

        intent.setClass(context, MFPPushNotificationHandler.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

        intent.putExtra(NOTIFICATIONID, message.getNotificationId());

        generateNotification(context, message.getAlert(), getNotificationTitle(context), message.getAlert(),
                getCustomNotificationIcon(context, message.getIcon()), intent, getNotificationSound(message),
                notificationId, message);
    }/*from ww w .ja va 2s  . com*/
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java

@Override
public void activate(Context context, SignedObj obj) {
    JSONObject content = obj.getJson();/*w  ww .  j a  va2 s  .c om*/
    //linkify should have picked it up already but if we are in TV mode we
    //still need to activate
    Intent intent = new Intent(Intent.ACTION_VIEW);
    String text = content.optString(URI);
    //some shared links come in with two lines of text "title\nuri"
    //for example google maps does this and passes that same value as both the
    //uri and title

    //launch the first thing that looks like a link
    Matcher m = p.matcher(text);
    while (m.find()) {
        Uri uri = Uri.parse(m.group());
        String scheme = uri.getScheme();

        if (scheme != null && (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))) {
            String type = content.optString(MIME_TYPE);
            if (type != null && type.length() > 0) {
                intent.setDataAndType(uri, type);
            } else {
                intent.setData(uri);
            }
            if (!(context instanceof Activity)) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            try {
                context.startActivity(intent);
            } catch (ActivityNotFoundException e) {
                String msg;
                if (type != null)
                    msg = "A third party application that supports " + type + " is required.";
                else
                    msg = "A third party application that supports " + uri.getScheme() + " is required.";
                Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
            }
            return;
        }
    }
}