Example usage for android.content Intent setAction

List of usage examples for android.content Intent setAction

Introduction

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

Prototype

public @NonNull Intent setAction(@Nullable String action) 

Source Link

Document

Set the general action to be performed.

Usage

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java

private void sendToDbFriend() {
    Intent send = new Intent(getActivity(), PickContactsActivity.class);
    send.setAction(PickContactsActivity.INTENT_ACTION_INVITE_TO_THREAD);
    send.putExtra("uri", mFeedUri);
    startActivity(send);//from   w w w  .  ja va  2 s  . c  om
}

From source file:com.money.manager.ex.settings.PerDatabaseFragment.java

private void showCurrencyChangeNotification() {
    new MaterialDialog.Builder(getActivity()).title(R.string.base_currency_changed)
            .content(R.string.base_currency_change_notification).positiveText(android.R.string.ok)
            .neutralText(R.string.open_currencies).onNeutral(new MaterialDialog.SingleButtonCallback() {
                @Override//from w  w  w. jav a 2s . c o  m
                public void onClick(MaterialDialog dialog, DialogAction which) {
                    Intent intent = new Intent(getActivity(), CurrencyListActivity.class);
                    intent.setAction(Intent.ACTION_EDIT);
                    startActivity(intent);
                }
            }).show();
}

From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
        @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
    case PermissionUtils.MY_PERMISSIONS_REQUEST_CAMERA: {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            startActivity(ScannerActivity.getStartIntent(this));
        } else {/*from   w ww .  j  av  a 2  s .  c  om*/
            new MaterialDialog.Builder(this).title(R.string.permission_title)
                    .content(R.string.permission_denied).negativeText(R.string.txt_no)
                    .positiveText(R.string.txt_yes).onPositive((dialog, which) -> {
                        Intent intent = new Intent();
                        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                        Uri uri = Uri.fromParts("package", getPackageName(), null);
                        intent.setData(uri);
                        startActivity(intent);
                    }).show();
        }
        break;
    }
    }
}

From source file:com.money.manager.ex.settings.PerDatabaseFragment.java

/**
 * select the base currency in a currency picker instead of a list.
 *///from   ww w  . j  a  v  a  2  s . co m
private void initBaseCurrency() {
    Preference baseCurrency = findPreference(getString(PreferenceConstants.PREF_BASE_CURRENCY));
    if (baseCurrency == null)
        return;

    // Display the current default currency as the summary.
    showCurrentDefaultCurrency();

    // After the currency is selected in the Currencies screen, the change is handled
    // in onActivityResult

    Preference.OnPreferenceClickListener clickListener = new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            // show the currencies activity
            Intent intent = new Intent(getActivity(), CurrencyListActivity.class);
            intent.setAction(Intent.ACTION_PICK);
            startActivityForResult(intent, REQUEST_PICK_CURRENCY);

            return true;
        }
    };

    baseCurrency.setOnPreferenceClickListener(clickListener);
}

From source file:cw.kop.autobackground.settings.AppSettingsFragment.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    if (!((Activity) appContext).isFinishing()) {
        Preference pref = findPreference(key);

        if (key.equals("use_notification")) {

            Intent intent = new Intent();
            intent.setAction(LiveWallpaperService.UPDATE_NOTIFICATION);
            intent.putExtra("use", ((SwitchPreference) pref).isChecked());
            appContext.sendBroadcast(intent);

            Log.i("WSF", "Toggle Notification");

        }//from w ww .  j  av a 2s . c o  m

        if (key.equals("use_toast")) {
            if (!AppSettings.useToast()) {
                showToastDialog();
            }
        }
    }

}

From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java

/**
 * Pick file from device./*from w w w  . j a va 2  s .c o  m*/
 */
public void pickFile() {
    Intent intent = new Intent();

    // Any type of file may be picked
    intent.setType("*/*");

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    if (this.cordova != null) {
        this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, "Pick File"), 0);
    }
}

From source file:io.coldstart.android.GCMIntentService.java

private void sendBatchNotification(String batchCount) {
    if (null == batchCount)
        batchCount = "1+";

    Intent intent = new Intent(this, TrapListActivity.class);
    intent.putExtra("forceDownload", true);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

    Intent broadcastDownload = new Intent();
    broadcastDownload.setAction(BatchDownloadReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastDownload = PendingIntent.getBroadcast(this, 0, broadcastDownload, 0);

    Intent broadcastIgnore = new Intent();
    broadcastIgnore.setAction(BatchIgnoreReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastIgnore = PendingIntent.getBroadcast(this, 0, broadcastIgnore, 0);

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

    Notification notification = null;

    if (Build.VERSION.SDK_INT >= 16) {
        notification = new Notification.InboxStyle(
                new Notification.Builder(this).setContentTitle("A batch of Traps has been sent")
                        .setContentText("\"Batched traps are waiting to be downloaded")
                        .setSmallIcon(R.drawable.ic_stat_ratelimit).setVibrate(new long[] { 0, 100, 200, 300 })
                        .setAutoCancel(true).setSound(uri).setPriority(Notification.PRIORITY_HIGH)
                        .setTicker("A batch of Traps has been sent")
                        .addAction(R.drawable.ic_download_batch, "Get Batched Traps", pBroadcastDownload)
                        .addAction(R.drawable.ic_ignore, "Ignore Batch", pBroadcastIgnore))
                                .setBigContentTitle("A batch of Traps has been sent")
                                .setSummaryText("Launch ColdStart.io to Manage These Events")
                                .addLine("A number of traps have been sent and batched for delivery")
                                .addLine("The current number of items queued is " + batchCount).addLine(" ")
                                .addLine("Tap \"Get Batched Traps\" to download the cached traps")
                                .addLine("Tap \"Ignore Batch\" to delete them from the server.")

                                .build();
    } else {/*from   ww w  . j av a 2 s  . c o m*/
        notification = new Notification.Builder(this).setContentTitle("A batch of Traps has been sent")
                .setContentText(
                        "A number of traps have been sent and batched for delivery. The current number of items queued is "
                                + batchCount
                                + "\nTap \"Get Alerts\" to batch download the outstanding traps or tap \"Ignore\" to delete them from the server.")
                .setSmallIcon(R.drawable.ic_stat_ratelimit).setContentIntent(pIntent)
                .setVibrate(new long[] { 0, 100, 200, 300 }).setAutoCancel(true).setSound(uri).build();
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    notificationManager.notify(43524, notification);
}

From source file:io.coldstart.android.GCMIntentService.java

private void sendRateLimitNotification(String rateLimitCount) {
    if (null == rateLimitCount)
        rateLimitCount = "0";

    Intent intent = new Intent(this, TrapListActivity.class);
    intent.putExtra("forceDownload", true);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

    Intent broadcastDownload = new Intent();
    broadcastDownload.setAction(BatchDownloadReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastDownload = PendingIntent.getBroadcast(this, 0, broadcastDownload, 0);

    Intent broadcastIgnore = new Intent();
    broadcastIgnore.setAction(BatchIgnoreReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastIgnore = PendingIntent.getBroadcast(this, 0, broadcastIgnore, 0);

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

    Notification notification = null;

    if (Build.VERSION.SDK_INT >= 16) {
        notification = new Notification.InboxStyle(new Notification.Builder(this)
                .setContentTitle("Inbound Traps have been rate limited")
                .setContentText(/*www .  j  av  a 2  s.c o m*/
                        "\"The number of traps being relayed to your phone has breeched the rate limit.")
                .setSmallIcon(R.drawable.ic_stat_ratelimit).setVibrate(new long[] { 0, 100, 200, 300 })
                .setAutoCancel(true).setSound(uri).setPriority(Notification.PRIORITY_HIGH)
                .setTicker("Inbound Traps have been rate limited")
                .addAction(R.drawable.ic_download_batch, "Get Batched Traps", pBroadcastDownload)
                .addAction(R.drawable.ic_ignore, "Ignore Batch", pBroadcastIgnore))
                        .setBigContentTitle("Inbound Traps have been rate limited")
                        .setSummaryText("Launch ColdStart.io to Manage These Events")
                        .addLine("The number of traps relayed to you has breeched the rate limit.")
                        .addLine("The current number of items queued is " + rateLimitCount).addLine(" ")
                        .addLine("Tap \"Get Batched Traps\" to download the cached traps")
                        .addLine("Tap \"Ignore Batch\" to delete them from the server.")

                        .build();
    } else {
        notification = new Notification.Builder(this).setContentTitle("Inbound Traps have been rate limited")
                .setContentText(
                        "The number of traps being relayed to your phone has breeched the rate limit. The current number of items queued is "
                                + rateLimitCount
                                + "\nTap \"Get Alerts\" to batch download the outstanding traps or tap \"Ignore\" to delete them from the server.")
                .setSmallIcon(R.drawable.ic_stat_ratelimit).setContentIntent(pIntent)
                .setVibrate(new long[] { 0, 100, 200, 300 }).setAutoCancel(true).setSound(uri).build();
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    notificationManager.notify(43524, notification);
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT)
            .equals(MainActivity.HOLO_LIGHT))
        inflater.inflate(R.menu.main, menu);
    else/*from  w  w  w.  ja v  a 2  s.co m*/
        inflater.inflate(R.menu.main_dark, menu);
    menu.findItem(R.id.action_search).setVisible(true);
    menu.findItem(R.id.action_refresh).setVisible(true);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    mSearchView.setQueryHint("Lookup Users");
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // Do nothing
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d("searching", mSearchView.getQuery() + "");
            Intent intent = new Intent();
            intent.putExtra("username", mSearchView.getQuery().toString());
            intent.setAction(ImgurHoloActivity.ACCOUNT_INTENT);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(intent);
            return true;
        }
    };
    mSearchView.setOnQueryTextListener(queryTextListener);
}

From source file:sjizl.com.FileUploadTest2.java

public void openGallery(int req_code) {

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select file to upload "), req_code);
}