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:Main.java

public static boolean startActivityUsingScheme(Activity a, String scheme, Bundle args) {
    Uri uri = Uri.parse(scheme + "://");
    Intent intent = new Intent(Intent.ACTION_RUN, uri);
    boolean result = true;
    try {/*w ww .  jav a2s  .  c o  m*/
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (args != null)
            intent.putExtras(args);
        a.startActivity(intent);
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:Main.java

public static boolean startActivityUsingScheme(Context a, String scheme) {
    Uri uri = Uri.parse(scheme + "://");
    Intent intent = new Intent(Intent.ACTION_RUN, uri);
    boolean result = true;
    try {//  w ww  .  jav  a 2 s .c om
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        a.startActivity(intent);
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:a14n.geolocationdemo.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Reload the Flutter Dart code when the activity receives an intent
    // from the "flutter refresh" command.
    // This feature should only be enabled during development.  Use the
    // debuggable flag as an indicator that we are in development mode.
    if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        if (Intent.ACTION_RUN.equals(intent.getAction())) {
            flutterView.runFromBundle(intent.getDataString(), intent.getStringExtra("snapshot"));
        }/*ww w .  jav  a2s .co m*/
    }
}

From source file:com.max2idea.android.fwknop.Fwknop.java

private void startApp() {
    Intent i = new Intent(Intent.ACTION_RUN);
    i.setComponent(new ComponentName("org.connectbot", "org.connectbot.HostListActivity"));
    PackageManager p = this.getPackageManager();
    List list = p.queryIntentActivities(i, p.COMPONENT_ENABLED_STATE_DEFAULT);
    if (list.isEmpty()) {
        Log.v("SPA", "ConnectBot is not installed");
        Toast.makeText(this, "ConnectBot is not installed", Toast.LENGTH_LONG).show();
    } else {//  w  w  w .  jav a2s .c om
        Log.v("SPA", "Starting connectBot");
        Toast.makeText(this, "Starting ConnectBot", Toast.LENGTH_LONG);
        startActivity(i);
    }
}

From source file:com.shinymayhem.radiopresets.ActivityMain.java

protected void bindRadioPlayer() {
    if (LOCAL_LOGV)
        log("binding radio player", "v");
    Intent intent = new Intent(this, ServiceRadioPlayer.class);
    intent.setAction(Intent.ACTION_RUN);
    startService(intent);/*w  ww.  ja  v  a 2 s . com*/

    //don't call service's onStartCommand, just connect to it so play(url) and other functions are available through ui
    //bind_above_client so ui might be killed before service, in case of low memory 
    //bindService(intent, mConnection, Context.BIND_AUTO_CREATE|Context.BIND_ABOVE_CLIENT);
    //bindService(intent, mConnection, Context.BIND_ABOVE_CLIENT); 
    bindService(intent, mConnection, 0);
}

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (LOCAL_LOGV)
        log("onStartCommand()", "v");

    //check if resuming after close for memory, or other crash
    if ((flags & Service.START_FLAG_REDELIVERY) != 0) {
        //maybe handle this with dialog and tap to resume
        if (LOCAL_LOGD)
            log("Intent redelivery, restarting", "d");
    }/*from   w  w  w.  j a  va 2  s .c  om*/

    mIntent = intent;
    if (intent == null) {
        if (LOCAL_LOGD)
            log("No intent", "w");
    } else {
        String action = intent.getAction();
        if (action == null) {
            if (LOCAL_LOGD)
                log("No action specified", "w"); //why?
            //return flag indicating no further action needed if service is stopped by system and later resumes
            return START_NOT_STICKY;
        } else if (action.equals(Intent.ACTION_RUN)) //called when service is being bound by player activity
        {
            if (LOCAL_LOGV)
                log("service being started probably so it can be bound", "v");
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_PLAY.toString())) //Play intent
        {
            int preset = Integer.valueOf(intent.getIntExtra(ActivityMain.EXTRA_STATION_PRESET, 0));
            if (LOCAL_LOGD)
                log("PLAY action in intent. Preset in extra:" + String.valueOf(preset), "d");
            play(preset);
            //return START_REDELIVER_INTENT;
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_PLAY_STREAM.toString())) //Play intent
        {
            if (LOCAL_LOGV)
                log("PLAY_STREAM action in intent", "v");
            String url = intent.getStringExtra(EXTRA_URL);
            if (LOCAL_LOGD)
                log("URL in extra:" + url, "d");
            //check whether the url should be updated (for metadata retrieval purposes)
            boolean updateUrl = intent.getBooleanExtra(EXTRA_UPDATE_URL, false);
            if (updateUrl) {
                mUrl = url;
            }
            playUrl(url);
            //return START_REDELIVER_INTENT;
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_UNSUPPORTED_FORMAT_ERROR.toString())) {

            String format = intent.getStringExtra(EXTRA_FORMAT);
            if (LOCAL_LOGD)
                log("Known unsupported format: " + format, "d");
            String title = getResources().getString(R.string.error_title);
            String message = getResources().getString(R.string.error_format) + ":" + format;
            mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR;
            //set 'now playing' to error
            stopInfo(getResources().getString(R.string.status_error));
            this.getErrorNotification(title, message);
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_FORMAT_ERROR.toString())) {
            String message = intent.getStringExtra(EXTRA_ERROR_MESSAGE);
            if (LOCAL_LOGD)
                log("URL was unable to play:" + message, "d");
            String title = getResources().getString(R.string.error_title);
            mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR;
            //set 'now playing' to error
            stopInfo(getResources().getString(R.string.status_error));
            this.getErrorNotification(title, message);
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_STREAM_ERROR.toString())) {

            int responseCode = intent.getIntExtra(EXTRA_RESPONSE_CODE, 0);
            String responseMessage = intent.getStringExtra(EXTRA_RESPONSE_MESSAGE);
            if (LOCAL_LOGD)
                log("Stream error. Code:" + String.valueOf(responseCode) + ", Message:" + responseMessage, "d");
            String title = getResources().getString(R.string.error_title);
            String message;
            switch (responseCode) {
            case 404:
                message = getResources().getString(R.string.error_not_found);
                break;
            case 400:
                if (responseMessage.equals("Server Full")) {
                    message = getResources().getString(R.string.error_server_full);
                } else {
                    message = getResources().getString(R.string.error_unknown);
                }
                break;
            default:
                message = getResources().getString(R.string.error_unknown);
            }
            mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR;
            //set 'now playing' to error
            stopInfo(getResources().getString(R.string.status_error));
            this.getErrorNotification(title, message);
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_NEXT.toString())) //Next preset intent
        {
            if (LOCAL_LOGD)
                log("NEXT action in intent", "d");
            nextPreset();
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_PREVIOUS.toString())) //Previous preset intent
        {
            if (LOCAL_LOGD)
                log("PREVIOUS action in intent", "d");
            previousPreset();
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_STOP.toString())) //Stop intent
        {
            if (LOCAL_LOGD)
                log("STOP action in intent", "d");
            end();
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_LIKE.toString())) //Stop intent
        {
            if (intent.hasExtra(EXTRA_SET_TRUE)) {
                boolean set = intent.getBooleanExtra(EXTRA_SET_TRUE, false);
                if (set) {
                    if (LOCAL_LOGD)
                        log("LIKE action in intent with true", "d");
                    this.like();
                } else {
                    if (LOCAL_LOGD)
                        log("LIKE action in intent with false", "d");
                    this.unlike();
                }
            }

            return START_NOT_STICKY;
        } else if (action.equals(ACTION_DISLIKE.toString())) //Stop intent
        {
            if (intent.hasExtra(EXTRA_SET_TRUE)) {
                boolean set = intent.getBooleanExtra(EXTRA_SET_TRUE, true);
                if (set) {
                    if (LOCAL_LOGD)
                        log("DISLIKE action in intent with true", "d");
                    this.dislike();
                } else {
                    if (LOCAL_LOGD)
                        log("DISLIKE action in intent with false", "d");
                    this.undislike();
                }
            }
            return START_NOT_STICKY;
        } else if (action.equals(ACTION_PULL_WIDGET_INFO.toString())) {
            if (LOCAL_LOGV)
                log("UPDATE_WIDGET action in intent", "v");
            updateDetails();
            endIfNotNeeded();

            return START_NOT_STICKY;
        } else {
            log("Unknown Action:" + action, "w");
        }
    }

    //return START_STICKY;
    return START_NOT_STICKY;
    //return START_REDELIVER_INTENT;
}

From source file:nl.sogeti.android.gpstracker.actions.Statistics.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean handled = false;
    Intent intent;//from www . j av  a2 s.  c o m
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        handled = true;
        break;
    case MENU_GRAPHTYPE:
        showDialog(DIALOG_GRAPHTYPE);
        handled = true;
        break;
    case MENU_TRACKLIST:
        intent = new Intent(this, TrackList.class);
        intent.putExtra(Tracks._ID, mTrackUri.getLastPathSegment());
        startActivityForResult(intent, MENU_TRACKLIST);
        break;
    case MENU_SHARE:
        intent = new Intent(Intent.ACTION_RUN);
        intent.setDataAndType(mTrackUri, Tracks.CONTENT_ITEM_TYPE);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Bitmap bm = mViewFlipper.getDrawingCache();
        Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm);
        intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri);
        startActivityForResult(Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE);
        handled = true;
        break;
    default:
        handled = super.onOptionsItemSelected(item);
    }
    return handled;
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    boolean handled = false;
    AdapterView.AdapterContextMenuInfo info;
    try {/*  w  ww .j a  va 2 s .  c  o  m*/
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e(this, "Bad menuInfo", e);
        return handled;
    }

    Object listItem = getListAdapter().getItem(info.position);
    if (listItem instanceof Cursor) {
        Cursor cursor = (Cursor) listItem;
        mDialogTrackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, cursor.getLong(0));
        mDialogCurrentName = cursor.getString(1);
        mDialogCurrentName = mDialogCurrentName != null ? mDialogCurrentName : "";
        switch (item.getItemId()) {
        case MENU_DELETE: {
            showDialog(DIALOG_DELETE);
            handled = true;
            break;
        }
        case MENU_SHARE: {
            Intent actionIntent = new Intent(Intent.ACTION_RUN);
            actionIntent.setDataAndType(mDialogTrackUri, Tracks.CONTENT_ITEM_TYPE);
            actionIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(actionIntent, getString(R.string.share_track)));
            handled = true;
            break;
        }
        case MENU_RENAME: {
            showDialog(DIALOG_RENAME);
            handled = true;
            break;
        }
        case MENU_STATS: {
            Intent actionIntent = new Intent(this, Statistics.class);
            actionIntent.setData(mDialogTrackUri);
            startActivity(actionIntent);
            handled = true;
            break;
        }
        default:
            handled = super.onContextItemSelected(item);
            break;
        }
    }
    return handled;
}

From source file:io.flutter.embedding.android.FlutterActivity.java

/**
 * The path to the bundle that contains this Flutter app's resources, e.g., Dart code snapshots.
 * <p>//from   w  ww  .  j a v a  2s .  c  o m
 * When this {@code FlutterActivity} is run by Flutter tooling and a data String is included
 * in the launching {@code Intent}, that data String is interpreted as an app bundle path.
 * <p>
 * By default, the app bundle path is obtained from {@link FlutterMain#findAppBundlePath(Context)}.
 * <p>
 * Subclasses may override this method to return a custom app bundle path.
 */
@NonNull
protected String getAppBundlePath() {
    // If this Activity was launched from tooling, and the incoming Intent contains
    // a custom app bundle path, return that path.
    // TODO(mattcarroll): determine if we should have an explicit FlutterTestActivity instead of conflating.
    if (isDebuggable() && Intent.ACTION_RUN.equals(getIntent().getAction())) {
        String appBundlePath = getIntent().getDataString();
        if (appBundlePath != null) {
            return appBundlePath;
        }
    }

    // Return the default app bundle path.
    // TODO(mattcarroll): move app bundle resolution into an appropriately named class.
    return FlutterMain.findAppBundlePath(getApplicationContext());
}

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

/**
 * Schedules to be woken up at the next notification time.
 *//*from w  w w . j  a v a2  s  .com*/
private static void scheduleNext(Context context) {
    // Get first future notification
    final Calendar now = Calendar.getInstance();
    final List<cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification> notifications = cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification
            .getNotificationsWithTime(context, now.getTimeInMillis(), false);

    // if not empty, schedule alarm wake up
    if (!notifications.isEmpty()) {
        // at first's time
        // Create a new PendingIntent and add it to the AlarmManager
        Intent intent = new Intent(Intent.ACTION_RUN);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 1, intent,
                PendingIntent.FLAG_CANCEL_CURRENT);
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.cancel(pendingIntent);
        am.set(AlarmManager.RTC_WAKEUP, notifications.get(0).time, pendingIntent);
    }

    monitorUri(context);
}