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:au.com.micropacific.cordova.DataReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // If intent of the Intent_SOFTTRIGGER_DATA string is received
    if (intent.getAction().equals(GeneralString.Intent_SOFTTRIGGER_DATA)) {

        // fetch the data within the intent
        String data = intent.getStringExtra(GeneralString.BcReaderData);

        // display the fetched data
        //e1.setText(data);
        Log.v("CipherlabRS30Plugin", "got data, 1: " + data);
        this.plugin.receieveScan(data);
    } else if (intent.getAction().equals(GeneralString.Intent_PASS_TO_APP)) {

        // fetch the data within the intent
        String data = intent.getStringExtra(GeneralString.BcReaderData);

        // display the fetched data
        //e1.setText(data);
        Log.v("CipherlabRS30Plugin", "got data, 2: " + data);
        this.plugin.receieveScan(data);

    } else if (intent.getAction().equals(GeneralString.Intent_READERSERVICE_CONNECTED)) {

        BcReaderType myReaderType = mReaderManager.GetReaderType();
        //e1.setText(myReaderType.toString());

        ReaderOutputConfiguration settings = new ReaderOutputConfiguration();
        mReaderManager.Get_ReaderOutputConfiguration(settings);
        settings.enableKeyboardEmulation = KeyboardEmulationType.None;
        mReaderManager.Set_ReaderOutputConfiguration(settings);

        Log.v("CipherlabRS30Plugin", "got data, 3");

        /*NotificationParams settings = new NotificationParams();
        mReaderManager.Get_NotificationParams(settings);
                   //from w w w.  j  a va2s . c  o  m
        ReaderOutputConfiguration settings2 = new ReaderOutputConfiguration();
        mReaderManager.Get_ReaderOutputConfiguration(settings2);
        */
    }

}

From source file:com.google.android.apps.muzei.SourceSubscriberService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null || intent.getAction() == null) {
        return;//from  w  w w.  ja  v a2s  .  c om
    }

    String action = intent.getAction();
    if (!ACTION_PUBLISH_STATE.equals(action)) {
        return;
    }
    // Handle API call from source
    String token = intent.getStringExtra(EXTRA_TOKEN);
    ComponentName selectedSource = SourceManager.getSelectedSource(this);
    if (selectedSource == null || !TextUtils.equals(token, selectedSource.flattenToShortString())) {
        Log.w(TAG, "Dropping update from non-selected source, token=" + token + " does not match token for "
                + selectedSource);
        return;
    }

    SourceState state = null;
    if (intent.hasExtra(EXTRA_STATE)) {
        Bundle bundle = intent.getBundleExtra(EXTRA_STATE);
        if (bundle != null) {
            state = SourceState.fromBundle(bundle);
        }
    }

    if (state == null) {
        // If there is no state, there is nothing to change
        return;
    }

    ContentValues values = new ContentValues();
    values.put(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME, selectedSource.flattenToShortString());
    values.put(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED, true);
    values.put(MuzeiContract.Sources.COLUMN_NAME_DESCRIPTION, state.getDescription());
    values.put(MuzeiContract.Sources.COLUMN_NAME_WANTS_NETWORK_AVAILABLE, state.getWantsNetworkAvailable());
    JSONArray commandsSerialized = new JSONArray();
    int numSourceActions = state.getNumUserCommands();
    boolean supportsNextArtwork = false;
    for (int i = 0; i < numSourceActions; i++) {
        UserCommand command = state.getUserCommandAt(i);
        if (command.getId() == MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK) {
            supportsNextArtwork = true;
        } else {
            commandsSerialized.put(command.serialize());
        }
    }
    values.put(MuzeiContract.Sources.COLUMN_NAME_SUPPORTS_NEXT_ARTWORK_COMMAND, supportsNextArtwork);
    values.put(MuzeiContract.Sources.COLUMN_NAME_COMMANDS, commandsSerialized.toString());
    ContentResolver contentResolver = getContentResolver();
    Cursor existingSource = contentResolver.query(MuzeiContract.Sources.CONTENT_URI,
            new String[] { BaseColumns._ID }, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + "=?",
            new String[] { selectedSource.flattenToShortString() }, null, null);
    if (existingSource != null && existingSource.moveToFirst()) {
        Uri sourceUri = ContentUris.withAppendedId(MuzeiContract.Sources.CONTENT_URI,
                existingSource.getLong(0));
        contentResolver.update(sourceUri, values, null, null);
    } else {
        contentResolver.insert(MuzeiContract.Sources.CONTENT_URI, values);
    }
    if (existingSource != null) {
        existingSource.close();
    }

    Artwork artwork = state.getCurrentArtwork();
    if (artwork != null) {
        artwork.setComponentName(selectedSource);
        contentResolver.insert(MuzeiContract.Artwork.CONTENT_URI, artwork.toContentValues());

        // Download the artwork contained from the newly published SourceState
        startService(TaskQueueService.getDownloadCurrentArtworkIntent(this));
    }
}

From source file:ca.hoogit.garagepi.Controls.DoorControlService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (Consts.ACTION_DOORS_QUERY.equals(action)) {
            handleActionQuery();/*from   w  w  w . j  av a 2s . c  o  m*/
        } else if (Consts.ACTION_DOORS_TOGGLE.equals(action)) {
            String name = intent.getStringExtra(Consts.KEY_DOOR_ID);
            handleActionToggle(name);
        }
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.ActivityEditor.java

long getNoteId(@NonNull final Intent intent) {
    long retval = -1;
    if (intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction())
            || Intent.ACTION_VIEW.equals(intent.getAction()))) {
        if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
            // Find it in the extras. See DashClock extension for an example
            retval = intent.getLongExtra(Task.TABLE_NAME, -1);
        } else if ((intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
                || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
                || intent.getData().getPath().startsWith(Task.URI.getPath()))) {
            retval = Long.parseLong(intent.getData().getLastPathSegment());
        }/* w  w  w .jav  a 2 s  .com*/
    }
    return retval;
}

From source file:net.reichholf.dreamdroid.activities.SearchEpgActivity.java

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

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        setAdapter();//w  ww  .  j  ava 2s  .  c  om
        search();
    } else {
        finish();
    }

}

From source file:at.ac.uniklu.mobile.sportal.notification.GCMCampusService.java

@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    if (action == null) {
        Log.e(TAG, "no action specified");
    }/*from  ww w .  j  av  a 2s.c o m*/
    if (action.equals(ACTION_REGISTER)) {
        register(intent.getStringExtra(EXTRA_REGID));
    } else if (action.equals(ACTION_UNREGISTER)) {
        unregister(intent.getStringExtra(EXTRA_REGID));
    } else if (action.equals(ACTION_NOTIFY)) {
        notifyUser();
    }
}

From source file:com.example.plugin.PhoneListener.java

public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    this.phoneListenerCallbackId = null;
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override//from  www . jav a 2 s.  c o  m
            public void onReceive(Context context, Intent intent) {
                if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                    // State has changed
                    String phoneState = intent.hasExtra(TelephonyManager.EXTRA_STATE)
                            ? intent.getStringExtra(TelephonyManager.EXTRA_STATE)
                            : null;
                    String state;
                    // See if the new state is 'ringing', 'off hook' or 'idle'
                    if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                        // phone is ringing, awaiting either answering or canceling
                        state = "RINGING";
                        Log.i(LOG_TAG, state);
                    } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
                        // actually talking on the phone... either making a call or having answered one
                        state = "OFFHOOK";
                        Log.i(LOG_TAG, state);
                    } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                        // idle means back to no calls in or out. default state.
                        state = "IDLE";
                        Log.i(LOG_TAG, state);
                    } else {
                        state = TYPE_NONE;
                        Log.i(LOG_TAG, state);
                    }
                    updatePhoneState(state, true);
                }
            }
        };
        // register the receiver... this is so it doesn't have to be added to AndroidManifest.xml
        cordova.getActivity().registerReceiver(this.receiver, intentFilter);
        this.registered = true;
    }

}

From source file:alaindc.memenguage.RandomIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (action.startsWith(Constants.ACTION_RANDOM_START)) {
            handleActionRandomStart();//from   w  w w . ja  v a  2s .  co m
        } else if (action.startsWith(Constants.ACTION_RANDOM_WORD)) {
            handleActionRandomWord();
        }
    }
}

From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    destroyed = false;/* w  w  w  . j a  v a  2  s  .c  o  m*/
    if (getActionBar() != null)
        getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    Log.d("New Intent", intent.toString());
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
            Intent serviceIntent = new Intent(this, UploadService.class);
            if (intent.getExtras() == null)
                finish();
            serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM"));
            startService(serviceIntent);
            finish();
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        Log.d("sending", "sending multiple");
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.putParcelableArrayListExtra("images", list);
        startService(serviceIntent);
        finish();
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null
            && intent.getData().toString().startsWith("http://imgur.com/a")) {
        String uri = intent.getData().toString();
        album = uri.split("/")[4];
        Log.d("album", album);
        Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
        fetcher.execute();
    } else if (Intent.ACTION_VIEW.equals(action)
            && intent.getData().toString().startsWith("http://imgur.com/gallery/")) {
        String uri = intent.getData().toString();
        final String album = uri.split("/")[4];
        if (album.length() == 5) {
            Log.d("album", album);
            Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
            fetcher.execute();
        } else if (album.length() == 7) {
            Log.d("image", album);
            Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE);
            fetcher.execute();
        }
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) {
        String uri = intent.getData().toString();
        final String image = uri.split("/")[3].split("\\.")[0];
        Log.d("image", image);
        Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE);
        fetcher.execute();
    }
}

From source file:com.moto.miletus.application.ble.neardevice.NearDeviceNotification.java

@Override
public void onReceive(final Context context, final Intent intent) {
    Log.i(TAG, intent.toString());/*from   w w  w  . j a v a 2  s.c  om*/

    if (!intent.getAction().equals(Strings.NEAR_DEVICE)) {
        return;
    }

    this.context = context;
    this.systemService = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    findDevice();
}