Example usage for android.content Intent ACTION_RUN

List of usage examples for android.content Intent ACTION_RUN

Introduction

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

Prototype

String ACTION_RUN

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

Click Source Link

Document

Activity Action: Run the data, whatever that means.

Usage

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java

/**
 * Fires notifications that have elapsed and sets an alarm to be woken at
 * the next notification./*from   w w w  .j a  va2s  . c o  m*/
 * <p/>
 * If the intent action is ACTION_DELETE, will delete the notification with
 * the indicated ID, and cancel it from any active notifications.
 */
@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())
            || Intent.ACTION_RUN.equals(intent.getAction())) {
        // Can't cancel anything. Just schedule and notify at end
    } else {
        // Always cancel
        cancelNotification(context, intent.getData());

        if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) {
            // Just a notification
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .deleteOrReschedule(context, intent.getData());
        } else if (ACTION_SNOOZE.equals(intent.getAction())) {
            // msec/sec * sec/min * 30
            long delay30min = 1000 * 60 * 30;
            final Calendar now = Calendar.getInstance();

            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .setTime(context, intent.getData(), delay30min + now.getTimeInMillis());
        } else if (ACTION_COMPLETE.equals(intent.getAction())) {
            // Complete note
            Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1));
            // Delete notifications with the same task id
            cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
                    .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1));
        }
    }

    notifyPast(context, true);
    scheduleNext(context);
}

From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean handled = false;

    Uri trackUri;//from   ww  w  .  j ava  2s . c o m
    Intent intent;
    switch (item.getItemId()) {
    case MENU_LAYERS:
        showDialog(DIALOG_LAYERS);
        handled = true;
        break;
    case MENU_NOTE:
        intent = new Intent(this, InsertNote.class);
        startActivityForResult(intent, MENU_NOTE);
        handled = true;
        break;
    case MENU_SETTINGS:
        intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);
        handled = true;
        break;
    case MENU_TRACKLIST:
        intent = new Intent(this, TrackList.class);
        intent.putExtra(Tracks._ID, this.mTrackId);
        startActivityForResult(intent, MENU_TRACKLIST);
        break;
    case MENU_STATS:
        if (this.mTrackId >= 0) {
            intent = new Intent(this, Statistics.class);
            trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
            intent.setData(trackUri);
            startActivity(intent);
            handled = true;
            break;
        } else {
            showDialog(DIALOG_NOTRACK);
        }
        handled = true;
        break;
    case MENU_SHARE:
        if (this.mTrackId >= 0) {
            intent = new Intent(Intent.ACTION_RUN);
            trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
            intent.setDataAndType(trackUri, Tracks.CONTENT_ITEM_TYPE);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Bitmap bm = findViewById(R.id.mapScreen).getDrawingCache();
            if (bm != null) {
                Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm);
                intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri);
            }
            startActivityForResult(Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE);
        } else {
            showDialog(DIALOG_NOTRACK);
        }
        handled = true;
        break;
    case MENU_CONTRIB:
        showDialog(DIALOG_CONTRIB);
    default:
        handled = super.onOptionsItemSelected(item);
        break;
    }
    return handled;
}