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:net.reichholf.dreamdroid.activities.ShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;/*from   w  ww.  j  a  v  a  2s .  c  o  m*/
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = title;

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}

From source file:org.klnusbaum.udj.network.PlayerCommService.java

@Override
public void onHandleIntent(Intent intent) {
    Log.d(TAG, "In Player Comm Service");
    AccountManager am = AccountManager.get(this);
    final Account account = (Account) intent.getParcelableExtra(Constants.ACCOUNT_EXTRA);
    if (intent.getAction().equals(Intent.ACTION_INSERT)) {
        joinPlayer(intent, am, account, true);
    } else {//from   w  w w .  j  av a 2  s  .  com
        Log.d(TAG, "Unrecognized action of, it was " + intent.getAction());
    }
}

From source file:androidx.media.session.MediaButtonReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null || !Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())
            || !intent.hasExtra(Intent.EXTRA_KEY_EVENT)) {
        Log.d(TAG, "Ignore unsupported intent: " + intent);
        return;/*from  w  w w  . j ava2  s. c om*/
    }
    ComponentName mediaButtonServiceComponentName = getServiceComponentByAction(context,
            Intent.ACTION_MEDIA_BUTTON);
    if (mediaButtonServiceComponentName != null) {
        intent.setComponent(mediaButtonServiceComponentName);
        startForegroundService(context, intent);
        return;
    }
    ComponentName mediaBrowserServiceComponentName = getServiceComponentByAction(context,
            MediaBrowserServiceCompat.SERVICE_INTERFACE);
    if (mediaBrowserServiceComponentName != null) {
        PendingResult pendingResult = goAsync();
        Context applicationContext = context.getApplicationContext();
        MediaButtonConnectionCallback connectionCallback = new MediaButtonConnectionCallback(applicationContext,
                intent, pendingResult);
        MediaBrowserCompat mediaBrowser = new MediaBrowserCompat(applicationContext,
                mediaBrowserServiceComponentName, connectionCallback, null);
        connectionCallback.setMediaBrowser(mediaBrowser);
        mediaBrowser.connect();
        return;
    }
    throw new IllegalStateException("Could not find any Service that handles " + Intent.ACTION_MEDIA_BUTTON
            + " or implements a media browser service.");
}

From source file:com.magnet.mmx.client.MMXWakeupIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    //verify the message is a wakeup message
    String action = intent.getAction();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onHandleIntent(): action=" + action);
    }// ww  w. ja v  a 2  s .  c om
    if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
        GooglePlayServicesWrapper playServicesWrapper = GooglePlayServicesWrapper.getInstance(this);
        int messageType = playServicesWrapper.getGcmMessageType(intent);
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "onHandleIntent(): Received message type: " + messageType);
        }
        switch (messageType) {
        case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_SEND_ERROR:
        case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_DELETED:
        case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_SEND_EVENT:
            Log.w(TAG, "onHandleIntent(): Message type is not handled: " + messageType);
            break;
        case GooglePlayServicesWrapper.GCM_MESSAGE_TYPE_MESSAGE:
            //parse the GCM message
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "onHandleIntent(): Handling GCM message.  extras: " + intent.getExtras());
            }
            Bundle extras = intent.getExtras();
            String msg = extras.getString("msg");

            boolean isMmxHandle = false;
            if (msg != null) {
                try {
                    PushMessage pushMessage = PushMessage.decode(msg, MMXTypeMapper.getInstance());
                    isMmxHandle = handleMMXInternalPush(pushMessage);
                    Log.d(TAG, "isMmxHandle=" + isMmxHandle + ", pushMsg=" + pushMessage);
                } catch (UnknownTypeException ex) {
                    //This is not an internal MMX message type
                    Log.i(TAG, "onHandleIntent() forwarding intent to application");
                } catch (Throwable e) {
                    Log.e(TAG, "onHandleIntent() generic exception caught while parsing GCM payload.", e);
                }
            }
            if (!isMmxHandle) {
                MMXClient.handleWakeup(this, intent);
            }
            break;
        }
        MMXGcmBroadcastReceiver.completeWakefulIntent(intent);
    } else {
        if (Intent.ACTION_BOOT_COMPLETED.equals(action) || MMXClient.ACTION_WAKEUP.equals(action)) {
            MMXClient.handleWakeup(this, intent);
        } else {
            //log and do nothing
            Log.w(TAG, "onHandleIntent(): Unsupported action: " + action);
        }
        MMXWakeupReceiver.completeWakefulIntent(intent);
    }
}

From source file:gov.nasa.arc.geocam.talk.service.TalkServer.java

@Override
protected void onHandleIntent(Intent intent) {
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (intent.getAction().contentEquals(TalkServerIntent.INTENT_SYNCHRONIZE.toString())) {
        handleSynchronizeIntent();/*  w  ww .  jav  a2 s. c  o m*/
    } else if (intent.getAction().contentEquals(TalkServerIntent.INTENT_STORE_C2DM_ID.toString())) {
        String registrationId = intent.getStringExtra(TalkServerIntent.EXTRA_REGISTRATION_ID.toString());
        handleStoreRegistrationIdIntent(registrationId);
    } else if (intent.getAction().contentEquals(TalkServerIntent.INTENT_PUSHED_MESSAGE.toString())) {
        String messageId = intent.getStringExtra(TalkServerIntent.EXTRA_MESSAGE_ID.toString());
        handlePushedMessageIntent(messageId);
    } else if (intent.getAction().contentEquals(TalkServerIntent.INTENT_LOGIN.toString())) {
        handleLogin();
    }

}

From source file:it.iziozi.iziozi.gui.IORemoteImageSearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        searchImages(query);/*  w ww  .  j av  a 2s  .c  o  m*/
    }
}

From source file:com.sharky.BillingService.java

public void handleCommand(Intent intent, int startId) {
    String action = intent.getAction();
    if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) {
        String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID);
        confirmNotifications(startId, notifyIds);
    } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) {
        String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID);
        getPurchaseInformation(startId, new String[] { notifyId });
    } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) {
        String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA);
        String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE);
        purchaseStateChanged(startId, signedData, signature);
    } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) {
        long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1);
        int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE,
                ResponseCode.RESULT_ERROR.ordinal());
        ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex);
        checkResponseCode(requestId, responseCode);
    }//  w  w  w  . j  a v  a  2 s .  c om
}

From source file:com.cpyf.twelve.spies.qr.code.book.SearchBookContentsActivity.java

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

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();/*ww  w.  j a  v a 2 s. c o  m*/
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:com.andernity.launcher2.InstallShortcutReceiver.java

public void onReceive(Context context, Intent data) {
    if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
        return;//  w  w  w.  j a  v  a  2 s.  co  m
    }

    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (intent == null) {
        return;
    }
    // This name is only used for comparisons and notifications, so fall back to activity name
    // if not supplied
    String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    if (name == null) {
        try {
            PackageManager pm = context.getPackageManager();
            ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0);
            name = info.loadLabel(pm).toString();
        } catch (PackageManager.NameNotFoundException nnfe) {
            return;
        }
    }
    Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
    Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);

    // Queue the item up for adding if launcher has not loaded properly yet
    boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 || LauncherModel.getCellCountY() <= 0;

    PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent);
    info.icon = icon;
    info.iconResource = iconResource;
    if (mUseInstallQueue || launcherNotLoaded) {
        String spKey = LauncherApplication.getSharedPreferencesKey();
        SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
        addToInstallQueue(sp, info);
    } else {
        processInstallShortcut(context, info);
    }
}

From source file:com.pixmob.r2droid.DeviceRegistrationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final String action = intent.getAction();
    if (ACTION_C2DM_ERROR.equals(action)) {
        onC2DMError(intent.getStringExtra(KEY_ERROR));
    } else if (action != null) {
        return super.onStartCommand(intent, flags, startId);
    }//from   w  ww .j av  a  2  s. com
    return START_NOT_STICKY;
}