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:com.google.android.gcm.GCMBroadcastReceiver.java

@Override
public final void onReceive(Context context, Intent intent) {
    Log.v(TAG, "onReceive: " + intent.getAction());

    /*/*from   ww  w.  j a v  a2  s .  c o  m*/
    //Test
    for(String s : intent.getExtras().keySet())
       Log.v(TAG, "bogdan: " + "(" + s + ", " + intent.getExtras().getString(s) + ")");
            
    String bonus = intent.getExtras().getString("u");
    try {
     JSONObject obj = new JSONObject(bonus);
     Log.v(TAG, "bogdan type-> " + obj.getJSONObject("bonus").getInt("Type"));
     Log.v(TAG, "bogdan amount -> " + obj.getJSONObject("bonus").getInt("Amount"));
    } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    */

    String className = getGCMIntentServiceClassName(context);
    Log.v(TAG, "GCM IntentService class: " + className);
    // Delegates to the application-specific intent service.
    GCMBaseIntentService.runIntentInService(context, intent, className);
    setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
}

From source file:can.yrt.onebusaway.SearchActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        /*/*from   ww w.  j  av  a 2  s  .  c  om*/
        Intent wordIntent = new Intent(this, WordActivity.class);
        wordIntent.setData(intent.getData());
        startActivity(wordIntent);
        finish();
        */
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        doSearch(query);
    }
}

From source file:cl.chihau.holaauto.MessageReadReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "onReceive called");

    if (MyMessagingService.READ_ACTION.equals(intent.getAction())) {
        int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1);
        if (conversationId != -1) {
            Log.d(TAG, "Conversation " + conversationId + " was read");
            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
            notificationManager.cancel(conversationId);
        }/* ww  w.  ja  va2 s. c o  m*/
    }
}

From source file:androidx.core.app.NotificationCompatSideChannelService.java

@Override
public IBinder onBind(Intent intent) {
    if (intent.getAction().equals(NotificationManagerCompat.ACTION_BIND_SIDE_CHANNEL)) {
        // Block side channel service connections if the current sdk has no need for
        // side channeling.
        if (Build.VERSION.SDK_INT > NotificationManagerCompat.MAX_SIDE_CHANNEL_SDK_VERSION) {
            return null;
        }/*from ww w . j  av  a  2  s .co  m*/
        return new NotificationSideChannelStub();
    }
    return null;
}

From source file:com.dipesan.miniatm.miniatm.services.BluetoothConnexionManager.java

@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
    case BluetoothAdapter.ACTION_STATE_CHANGED:
        if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
            connect();//w w w.jav a2 s .c om
        }
        break;
    }
}

From source file:my.home.lehome.receiver.LocalMessageReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(LOCAL_MSG_RECEIVER_ACTION)) {
        if (PrefUtil.getbooleanValue(context, MainActivityPresenter.APP_EXIT_KEY, false)) {
            Log.d(TAG, "app set exit. ignore network state change.");
            return;
        }/*  w w w  .  j  av a  2 s.  c o m*/
        String lm = intent.getStringExtra(LOCAL_MSG_REP_KEY);
        Log.d(TAG, "receive local msg: " + lm);
        if (lm != null) {
            JSONTokener jsonParser = new JSONTokener(lm);
            String type = "";
            String msg = "";
            String err_msg = "";
            int seq = -1;
            try {
                JSONObject cmdObject = (JSONObject) jsonParser.nextValue();
                type = cmdObject.getString("type");
                msg = cmdObject.getString("msg");
                seq = cmdObject.getInt("seq");
                if (MessageHelper.enqueueMsgSeq(context, seq))
                    return;
            } catch (JSONException e) {
                e.printStackTrace();
                err_msg = context.getString(R.string.msg_push_msg_format_error);
            } catch (Exception e) {
                e.printStackTrace();
                err_msg = context.getString(R.string.msg_push_msg_format_error);
            }

            if (!TextUtils.isEmpty(err_msg)) {
                MessageHelper.sendToast(err_msg);
                return;
            }

            if (type.equals("req_loc") || type.equals("req_geo")) {
                LocationHelper.enqueueLocationRequest(context, seq, type, msg);
                return;
            } else if (Arrays.asList(MessageHelper.NORMAIL_FILTER_TAG_LIST).contains(type)) {
                MessageHelper.inNormalState = true;
            } else if (type.equals("toast")) {
                MessageHelper.sendToast(msg);
                return;
            } else {
                MessageHelper.inNormalState = false;
            }
            MessageHelper.sendServerMsgToList(seq, type, msg, context);
        }
    }
}

From source file:com.prey.receivers.C2DMReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION")) {
        handleRegistration(context, intent);
    } else if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
        handleMessage(context, intent);/*from  w  w  w.  j  a  v a  2s.  c om*/
    }
}

From source file:au.com.wallaceit.reddinator.MailCheckService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    action = intent.getAction();
    if (global.mRedditData.isLoggedIn())
        if (action.equals(ACTIVITY_CHECK_ACTION) || action.equals(NOTIFY_CHECK_ACTION)) {
            (new MailCheckTask()).execute();
        }//from   ww  w .java 2 s .  co m
    return START_NOT_STICKY;
}

From source file:de.micmun.android.workdaystarget.DaysLeftService.java

/**
 * @see android.app.IntentService#onHandleIntent(android.content.Intent)
 *///  ww  w .ja  v a  2s. c om
@Override
protected void onHandleIntent(Intent arg0) {
    if (arg0.getAction().equals(ACTION_UPDATE)) {
        updateDays();
    }
}

From source file:be.ppareit.swiftp.gui.FsNotification.java

@Override
public void onReceive(Context context, Intent intent) {
    Cat.d("onReceive broadcast: " + intent.getAction());
    switch (intent.getAction()) {
    case FsService.ACTION_STARTED:
        setupNotification(context);//from   w  w  w .  jav a2s .c o m
        break;
    case FsService.ACTION_STOPPED:
        clearNotification(context);
        break;
    }
}