Example usage for android.content Intent getAction

List of usage examples for android.content Intent getAction

Introduction

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

Prototype

public @Nullable String getAction() 

Source Link

Document

Retrieve the general action to be performed, such as #ACTION_VIEW .

Usage

From source file:com.orange.oidc.tim.service.Service.java

@Override
public IBinder onBind(Intent intent) {
    // Select the interface to return.  If your service only implements
    // a single interface, you can just return it here without checking
    // the Intent.
    if (IRemoteService.class.getName().equals(intent.getAction())) {
        showProtectedNotifIcon();//from ww  w .  j  ava2s  .  com
        Logd(TAG, "onBind Service");
        connectSEService();
        return mBinder;
    }
    if (IRemoteServiceInternal.class.getName().equals(intent.getAction())) {
        Logd(TAG, "onBind ServiceInternal");
        connectSEService();
        return mBinderInternal;
    }
    return null;
}

From source file:edu.cens.loci.ui.PlaceViewActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // parse incoming data
    final Intent intent = getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
        mUri = intent.getData();/*from   w  w  w . j  av a2s .c o  m*/
        if (mUri == null) {
            MyLog.e(LociConfig.D.ERROR, TAG, "intent.getData() is empty, exiting.");
            finish();
        }
        MyLog.d(LociConfig.D.UI.DEBUG, TAG, "mUri=" + mUri.toString());
    } else {
        MyLog.e(LociConfig.D.ERROR, TAG, "Unknown action, exiting.");
        finish();
        return;
    }
    mPlaceId = LociProvider.checkPlaceIdUri(mUri);

    if (mPlaceId < 0) {
        MyLog.e(LociConfig.D.ERROR, TAG, "Invalid uri, exiting.");
        finish();
    }

    mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.place_view);

    mNameView = (TextView) findViewById(R.id.name);
    mMapView = (MapView) findViewById(R.id.map);

    mListView = (ListView) findViewById(R.id.place_data);
    mListView.setOnItemClickListener(this);
    mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
    mListView.setEmptyView(findViewById(android.R.id.empty));

    mDbUtils = new LociDbUtils(this);

    mPlace = mDbUtils.getPlace(mPlaceId);

    //DEBUG
    MyLog.d(LociConfig.D.UI.DEBUG, TAG, "viewing..." + mPlace.toString());

    mHandler = new NotifyingAsyncQueryHandler(this, this);

    // The order they're added to mSections dictates the order they are diplayed in the list.
    mSections.add(mGpsEntries);
    mSections.add(mWifiEntries);
    mSections.add(mPostalEntries);
    mSections.add(mTagEntries);
    mSections.add(mWebsiteEntries);
    mSections.add(mOtherEntries);
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

/**
 * If this intent looks like a launch from icon/widget/etc, perform
 * launch actions.//from  ww  w  .  j av  a 2s.  c om
 */
private void checkForLaunch(Intent intent) {
    SharedPreferences settings = PlaybackService.getSettings(this);
    if (settings.getBoolean(PrefKeys.PLAYBACK_ON_STARTUP, PrefDefaults.PLAYBACK_ON_STARTUP)
            && Intent.ACTION_MAIN.equals(intent.getAction())) {
        startActivity(new Intent(this, FullPlaybackActivity.class));
    }
}

From source file:com.piusvelte.taplock.client.core.TapLockSettings.java

@Override
protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    if (mInWriteMode) {
        if (intent != null) {
            String action = intent.getAction();
            if (mInWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)
                    && intent.hasExtra(EXTRA_DEVICE_NAME)) {
                Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
                String name = intent.getStringExtra(EXTRA_DEVICE_NAME);
                if ((tag != null) && (name != null)) {
                    // write the device and address
                    String lang = "en";
                    // don't write the passphrase!
                    byte[] textBytes = name.getBytes();
                    byte[] langBytes = null;
                    int langLength = 0;
                    try {
                        langBytes = lang.getBytes("US-ASCII");
                        langLength = langBytes.length;
                    } catch (UnsupportedEncodingException e) {
                        Log.e(TAG, e.toString());
                    }/* w  w w .j  av a2  s .  c o m*/
                    int textLength = textBytes.length;
                    byte[] payload = new byte[1 + langLength + textLength];

                    // set status byte (see NDEF spec for actual bits)
                    payload[0] = (byte) langLength;

                    // copy langbytes and textbytes into payload
                    if (langBytes != null) {
                        System.arraycopy(langBytes, 0, payload, 1, langLength);
                    }
                    System.arraycopy(textBytes, 0, payload, 1 + langLength, textLength);
                    NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT,
                            new byte[0], payload);
                    NdefMessage message = new NdefMessage(
                            new NdefRecord[] { record, NdefRecord.createApplicationRecord(getPackageName()) });
                    // Get an instance of Ndef for the tag.
                    Ndef ndef = Ndef.get(tag);
                    if (ndef != null) {
                        try {
                            ndef.connect();
                            if (ndef.isWritable()) {
                                ndef.writeNdefMessage(message);
                            }
                            ndef.close();
                            Toast.makeText(this, "tag written", Toast.LENGTH_LONG).show();
                        } catch (IOException e) {
                            Log.e(TAG, e.toString());
                        } catch (FormatException e) {
                            Log.e(TAG, e.toString());
                        }
                    } else {
                        NdefFormatable format = NdefFormatable.get(tag);
                        if (format != null) {
                            try {
                                format.connect();
                                format.format(message);
                                format.close();
                                Toast.makeText(getApplicationContext(), "tag written", Toast.LENGTH_LONG);
                            } catch (IOException e) {
                                Log.e(TAG, e.toString());
                            } catch (FormatException e) {
                                Log.e(TAG, e.toString());
                            }
                        }
                    }
                    mNfcAdapter.disableForegroundDispatch(this);
                }
            }
        }
        mInWriteMode = false;
    } else {
        SharedPreferences sp = getSharedPreferences(KEY_PREFS, MODE_PRIVATE);
        onSharedPreferenceChanged(sp, KEY_DEVICES);
        // check if configuring a widget
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                final String[] displayNames = TapLock.getDeviceNames(mDevices);
                final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID);
                if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                    mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle("Select device for widget")
                            .setItems(displayNames, new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    // set the successful widget result
                                    Intent resultValue = new Intent();
                                    resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                                    setResult(RESULT_OK, resultValue);

                                    // broadcast the new widget to update
                                    JSONObject deviceJObj = mDevices.get(which);
                                    dialog.cancel();
                                    TapLockSettings.this.finish();
                                    try {
                                        sendBroadcast(TapLock
                                                .getPackageIntent(TapLockSettings.this, TapLockWidget.class)
                                                .setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
                                                .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
                                                .putExtra(EXTRA_DEVICE_NAME, deviceJObj.getString(KEY_NAME)));
                                    } catch (JSONException e) {
                                        Log.e(TAG, e.toString());
                                    }
                                }
                            }).create();
                    mDialog.show();
                }
            }
        }
        // start the service before binding so that the service stays around for faster future connections
        startService(TapLock.getPackageIntent(this, TapLockService.class));
        bindService(TapLock.getPackageIntent(this, TapLockService.class), this, BIND_AUTO_CREATE);

        int serverVersion = sp.getInt(KEY_SERVER_VERSION, 0);
        if (mShowTapLockSettingsInfo && (mDevices.size() == 0)) {
            if (serverVersion < SERVER_VERSION)
                sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit();
            mShowTapLockSettingsInfo = false;
            Intent i = TapLock.getPackageIntent(this, TapLockInfo.class);
            i.putExtra(EXTRA_INFO, getString(R.string.info_taplocksettings));
            startActivity(i);
        } else if (serverVersion < SERVER_VERSION) {
            // TapLockServer has been updated
            sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit();
            mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.ttl_hasupdate)
                    .setMessage(R.string.msg_hasupdate)
                    .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();

                            mDialog = new AlertDialog.Builder(TapLockSettings.this)
                                    .setTitle(R.string.msg_pickinstaller)
                                    .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.cancel();
                                            final String installer_file = getResources()
                                                    .getStringArray(R.array.installer_values)[which];

                                            mDialog = new AlertDialog.Builder(TapLockSettings.this)
                                                    .setTitle(R.string.msg_pickdownloader)
                                                    .setItems(R.array.download_entries,
                                                            new DialogInterface.OnClickListener() {

                                                                @Override
                                                                public void onClick(DialogInterface dialog,
                                                                        int which) {
                                                                    dialog.cancel();
                                                                    String action = getResources()
                                                                            .getStringArray(
                                                                                    R.array.download_values)[which];
                                                                    if (ACTION_DOWNLOAD_SDCARD.equals(action)
                                                                            && copyFileToSDCard(installer_file))
                                                                        Toast.makeText(TapLockSettings.this,
                                                                                "Done!", Toast.LENGTH_SHORT)
                                                                                .show();
                                                                    else if (ACTION_DOWNLOAD_EMAIL
                                                                            .equals(action)
                                                                            && copyFileToSDCard(
                                                                                    installer_file)) {
                                                                        Intent emailIntent = new Intent(
                                                                                android.content.Intent.ACTION_SEND);
                                                                        emailIntent.setType(
                                                                                "application/java-archive");
                                                                        emailIntent.putExtra(Intent.EXTRA_TEXT,
                                                                                getString(
                                                                                        R.string.email_instructions));
                                                                        emailIntent.putExtra(
                                                                                Intent.EXTRA_SUBJECT,
                                                                                getString(R.string.app_name));
                                                                        emailIntent.putExtra(
                                                                                Intent.EXTRA_STREAM,
                                                                                Uri.parse("file://"
                                                                                        + Environment
                                                                                                .getExternalStorageDirectory()
                                                                                                .getPath()
                                                                                        + "/"
                                                                                        + installer_file));
                                                                        startActivity(Intent.createChooser(
                                                                                emailIntent, getString(
                                                                                        R.string.button_getserver)));
                                                                    }
                                                                }

                                                            })
                                                    .create();
                                            mDialog.show();
                                        }
                                    }).create();
                            mDialog.show();
                        }
                    }).create();
            mDialog.show();
        }
    }
}

From source file:biz.wiz.android.wallet.service.BlockchainServiceImpl.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (intent != null) {
        log.info("service start command: " + intent
                + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)
                        ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")"
                        : ""));

        final String action = intent.getAction();

        if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) {
            notificationCount = 0;//ww  w.java  2 s.com
            notificationAccumulatedAmount = Coin.ZERO;
            notificationAddresses.clear();

            nm.cancel(NOTIFICATION_ID_COINS_RECEIVED);
        } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) {
            log.info("will remove blockchain on service shutdown");

            resetBlockchainOnShutdown = true;
            stopSelf();
        } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) {
            final Sha256Hash hash = new Sha256Hash(
                    intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH));
            final Transaction tx = application.getWallet().getTransaction(hash);

            if (peerGroup != null) {
                log.info("broadcasting transaction " + tx.getHashAsString());
                peerGroup.broadcastTransaction(tx);
            } else {
                log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
            }
        }
    } else {
        log.warn("service restart, although it was started as non-sticky");
    }

    return START_NOT_STICKY;
}

From source file:se.leap.bitmaskclient.ProviderAPI.java

@Override
protected void onHandleIntent(Intent command) {
    final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY);
    String action = command.getAction();
    Bundle parameters = command.getBundleExtra(PARAMETERS);

    if (provider_api_url == null && preferences.contains(Provider.KEY)) {
        try {/*from  w w  w.  j a v a 2 s .  co  m*/
            JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
            provider_api_url = provider_json.getString(Provider.API_URL) + "/"
                    + provider_json.getString(Provider.API_VERSION);
            go_ahead = true;
        } catch (JSONException e) {
            go_ahead = false;
        }
    }

    if (action.equalsIgnoreCase(SET_UP_PROVIDER)) {
        Bundle result = setUpProvider(parameters);
        if (go_ahead) {
            if (result.getBoolean(RESULT_KEY)) {
                receiver.send(PROVIDER_OK, result);
            } else {
                receiver.send(PROVIDER_NOK, result);
            }
        }
    } else if (action.equalsIgnoreCase(SIGN_UP)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources);
        Bundle result = tryToRegister(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_SIGNUP, result);
        } else {
            receiver.send(FAILED_SIGNUP, result);
        }
    } else if (action.equalsIgnoreCase(LOG_IN)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources);
        Bundle result = tryToAuthenticate(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources);
        } else {
            receiver.send(FAILED_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources);
        }
    } else if (action.equalsIgnoreCase(LOG_OUT)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources);
        if (logOut()) {
            receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources);
        } else {
            receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
        if (updateVpnCertificate()) {
            receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) {
        Bundle result = getAndSetEipServiceJson();
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        }
    }
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
@Config(shadows = { ShadowOneSignal.class })
public void shouldFireNotificationExtenderService() throws Exception {
    // Test that GCM receiver starts the NotificationExtenderServiceTest when it is in the AndroidManifest.xml
    Bundle bundle = getBaseNotifBundle();

    Intent serviceIntent = new Intent();
    serviceIntent.setPackage("com.onesignal.example");
    serviceIntent.setAction("com.onesignal.NotificationExtender");
    ResolveInfo resolveInfo = new ResolveInfo();
    resolveInfo.serviceInfo = new ServiceInfo();
    resolveInfo.serviceInfo.name = "com.onesignal.example.NotificationExtenderServiceTest";
    RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(serviceIntent, resolveInfo);

    boolean ret = OneSignalPackagePrivateHelper.GcmBroadcastReceiver_processBundle(blankActivity, bundle);
    Assert.assertTrue(ret);// w  w  w  . ja  v a  2 s . co  m

    Intent intent = Shadows.shadowOf(blankActivity).getNextStartedService();
    Assert.assertEquals("com.onesignal.NotificationExtender", intent.getAction());

    // Test that all options are set.
    NotificationExtenderServiceTest service = (NotificationExtenderServiceTest) startNotificationExtender(
            createInternalPayloadBundle(getBundleWithAllOptionsSet()), NotificationExtenderServiceTest.class);

    OSNotificationReceivedResult notificationReceived = service.notification;
    OSNotificationPayload notificationPayload = notificationReceived.payload;
    Assert.assertEquals("Test H", notificationPayload.title);
    Assert.assertEquals("Test B", notificationPayload.body);
    Assert.assertEquals("9764eaeb-10ce-45b1-a66d-8f95938aaa51", notificationPayload.notificationID);

    Assert.assertEquals(0, notificationPayload.lockScreenVisibility);
    Assert.assertEquals("FF0000FF", notificationPayload.smallIconAccentColor);
    Assert.assertEquals("703322744261", notificationPayload.fromProjectNumber);
    Assert.assertEquals("FFFFFF00", notificationPayload.ledColor);
    Assert.assertEquals("big_picture", notificationPayload.bigPicture);
    Assert.assertEquals("large_icon", notificationPayload.largeIcon);
    Assert.assertEquals("small_icon", notificationPayload.smallIcon);
    Assert.assertEquals("test_sound", notificationPayload.sound);
    Assert.assertEquals("You test $[notif_count] MSGs!", notificationPayload.groupMessage);
    Assert.assertEquals("http://google.com", notificationPayload.launchURL);
    Assert.assertEquals(10, notificationPayload.priority);
    Assert.assertEquals("a_key", notificationPayload.collapseId);

    Assert.assertEquals("id1", notificationPayload.actionButtons.get(0).id);
    Assert.assertEquals("button1", notificationPayload.actionButtons.get(0).text);
    Assert.assertEquals("ic_menu_share", notificationPayload.actionButtons.get(0).icon);
    Assert.assertEquals("id2", notificationPayload.actionButtons.get(1).id);
    Assert.assertEquals("button2", notificationPayload.actionButtons.get(1).text);
    Assert.assertEquals("ic_menu_send", notificationPayload.actionButtons.get(1).icon);

    Assert.assertEquals("test_image_url", notificationPayload.backgroundImageLayout.image);
    Assert.assertEquals("FF000000", notificationPayload.backgroundImageLayout.titleTextColor);
    Assert.assertEquals("FFFFFFFF", notificationPayload.backgroundImageLayout.bodyTextColor);

    JSONObject additionalData = notificationPayload.additionalData;
    Assert.assertEquals("myValue", additionalData.getString("myKey"));
    Assert.assertEquals("nValue", additionalData.getJSONObject("nested").getString("nKey"));

    Assert.assertNotSame(-1, service.notificationId);

    // Test a basic notification without anything special.
    startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle()),
            NotificationExtenderServiceTest.class);
    Assert.assertFalse(ShadowOneSignal.messages.contains("Error assigning"));

    // Test that a notification is still displayed if the developer's code in onNotificationProcessing throws an Exception.
    NotificationExtenderServiceTest.throwInAppCode = true;
    startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle("NewUUID1")),
            NotificationExtenderServiceTest.class);

    Assert.assertTrue(ShadowOneSignal.messages.contains("onNotificationProcessing throw an exception"));
    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Assert.assertEquals(3, postedNotifs.size());
}

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

@Override
protected void onNewIntent(Intent intent) {
    if (intent == null || isShutdown(intent)) {
        return;//from  w  w w  . ja  va 2  s  .c om
    }
    if (isGoHome(intent)) {
        finish();
        return;
    }
    String action = intent.getAction();
    if (action != null) {
        switch (action) {
        case Constants.ACTION_SHOW_TRANSFERS:
            intent.setAction(null);
            controller.showTransfers(TransferStatus.ALL);
            break;
        case Intent.ACTION_VIEW:
            openTorrentUrl(intent);
            break;
        case Constants.ACTION_START_TRANSFER_FROM_PREVIEW:
            if (Ref.alive(NewTransferDialog.srRef)) {
                SearchFragment.startDownload(this, NewTransferDialog.srRef.get(),
                        getString(R.string.download_added_to_queue));
                UXStats.instance().log(UXAction.DOWNLOAD_CLOUD_FILE_FROM_PREVIEW);
            }
            break;
        case Constants.ACTION_REQUEST_SHUTDOWN:
            UXStats.instance().log(UXAction.MISC_NOTIFICATION_EXIT);
            showShutdownDialog();
            break;
        }
    }
    if (intent.hasExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_NOTIFICATION)) {
        async(this, MainActivity::onDownloadCompleteNotification, intent);
    }
    if (intent.hasExtra(Constants.EXTRA_FINISH_MAIN_ACTIVITY)) {
        finish();
    }
}

From source file:com.lvlstudios.android.gtmessage.C2DMReceiver.java

@Override
public void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();//  w w  w.  j ava2s. c o  m
    if (extras != null) {
        String url = (String) extras.get("url");
        String title = (String) extras.get("title");
        String sel = (String) extras.get("sel");
        String debug = (String) extras.get("debug");
        Log.d(TAG, String.format("C2DMReceiver.onMessage: url='%s', title='%s', sel='%s'", url, title, sel));

        if (debug != null) {
            // server-controlled debug - the server wants to know we received the message, and when.
            // This is not user-controllable,
            // we don't want extra traffic on the server or phone. Server may
            // turn this on for a small percentage of requests or for users
            // who report issues.
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key"));
            // No auth - the purpose is only to generate a log/confirm delivery
            // (to avoid overhead of getting the token)
            try {
                client.execute(get);
            } catch (ClientProtocolException e) {
                // ignore
            } catch (IOException e) {
                // ignore
            }
        }

        if (title != null && url != null && url.startsWith("http")) {
            SharedPreferences settings = Prefs.get(context);
            Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel);

            // Notify and optionally start activity
            if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
                try {
                    context.startActivity(launchIntent);
                    LauncherUtils.playNotificationSound(context);
                } catch (ActivityNotFoundException e) {
                    return;
                }
            } else {
                if (sel != null && sel.length() > 0) { // have selection
                    LauncherUtils.generateNotification(context, sel,
                            context.getString(R.string.copied_desktop_clipboard), launchIntent);
                } else {
                    LauncherUtils.generateNotification(context, url, title, launchIntent);
                }
            }

            // Record history (for link/maps only)
            if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) {
                HistoryDatabase.get(context).insertHistory(title, url);
            }
        }
    }
}