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

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (ACTION_STOP.equals(intent.getAction())) {
        setFlashlight(false);//w  ww. j  a va  2 s .  c o m
    }
}

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

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

    if (MyMessagingService.REPLY_ACTION.equals(intent.getAction())) {
        int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1);
        CharSequence reply = getMessageText(intent);
        Log.d(TAG, "Got reply (" + reply + ") for ConversationId " + conversationId);

        // Tell the Service to send another message.
        Intent serviceIntent = new Intent(context, MyMessagingService.class);
        serviceIntent.setAction(MyMessagingService.SEND_MESSAGE_ACTION);
        context.startService(serviceIntent);
    }//from  w  w w.j  a v a  2s. c o  m
}

From source file:com.jesusla.google.BillingReceiver.java

/**
 * This is the entry point for all asynchronous messages sent from Android Market to
 * the application. This method forwards the messages on to the
 * {@link BillingService}, which handles the communication back to Android Market.
 * The {@link BillingService} also reports state changes back to the application through
 * the {@link ResponseHandler}./* w w  w  . j  av a2 s  .c  o m*/
 */
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) {
        String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA);
        String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE);
        purchaseStateChanged(context, signedData, signature);
    } else if (Consts.ACTION_NOTIFY.equals(action)) {
        String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID);
        if (Consts.DEBUG) {
            Log.i(TAG, "notifyId: " + notifyId);
        }
        notify(context, notifyId);
    } 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());
        checkResponseCode(context, requestId, responseCodeIndex);
    } else {
        Log.w(TAG, "unexpected action: " + action);
    }
}

From source file:com.chatwing.whitelabel.services.UpdateGcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    if (action == null)
        return;/*  w  w w.  j  av a  2s  .c o  m*/
    User user = (User) intent.getSerializableExtra(EXTRA_USER);
    if (user == null) {
        user = mUserManager.getCurrentUser();
    }
    if (action.equals(ApiManager.GCM_ACTION_ADD)) {
        addGcmRegistrationIdToBackend(user);
    } else if (action.equals(ApiManager.GCM_ACTION_REMOVE)) {
        removeGcmRegistrationIdFromBackend(user);
    }
}

From source file:com.nagopy.android.xposed.SettingChangedReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Object obj = dataObject.get();
    if (!StringUtils.equals(intent.getAction(), action) || obj == null) {
        context.unregisterReceiver(this);
        return;//from ww  w.ja  v a 2s. co m
    }

    Bundle extras = intent.getExtras();
    if (extras == null || extras.size() != 2) {
        return;
    }

    try {
        // target?value????????
        String target = extras.getString("target");
        Object value = extras.get("value");
        obj.getClass().getField(target).set(obj, value);

        onDataChanged();
    } catch (Throwable t) {
        Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t));
    }
}

From source file:emcewen.websms.services.C2DMRegistrationService.java

@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();

    if (REGISTER_WITH_MYSERVER.equals(action)) {
        this.registerForPush(intent.getStringExtra(REGISTRATION_ID), intent.getStringExtra(PUSH_USERNAME));
    } else if (UNREGISTER_WITH_C2DM.equals(action)) {
        this.unregisterFromC2dm();
    } else if (REGISTER_WITH_C2DM.equals(action)) {
        this.registerToC2dm();
    } else if (UNREGISTER_WITH_MYSERVER.equals(action)) {
        this.unregisterForPush();
    }//w ww  . jav a2 s  . c  o  m

}

From source file:com.szanata.cordova.phonestatechangelistener.PhoneStateChangeListener.java

/**
 * creates a new BroadcastReceiver to listen whether the Telephony State changes
 *//*ww w. ja v  a  2 s. co m*/
public void startPhoneListener(final CallbackContext callbackContext) {

    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {

            @Override
            public void onReceive(final Context context, final Intent intent) {

                if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                    String state = intent.hasExtra(TelephonyManager.EXTRA_STATE)
                            ? intent.getStringExtra(TelephonyManager.EXTRA_STATE)
                            : NONE;
                    String number = "";

                    if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                        number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
                    }

                    final JSONObject data = new JSONObject();
                    try {
                        data.put("state", state);
                        data.put("number", number);
                        callbackContext.success(data);
                    } catch (final JSONException e) {
                        callbackContext.error(e.getMessage());
                    }

                }
            }
        };

        this.context.registerReceiver(this.receiver,
                new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED));
    }
}

From source file:com.clover.sdk.v1.app.AppNotification.java

public AppNotification(Intent intent) {
    Assert.assertEquals(AppNotificationIntent.ACTION_APP_NOTIFICATION, intent.getAction());
    appEvent = intent.getStringExtra(AppNotificationIntent.EXTRA_APP_EVENT);
    payload = intent.getStringExtra(AppNotificationIntent.EXTRA_PAYLOAD);
}

From source file:com.szanata.cordova.plugins.PhoneStateChangeListener.java

/**
 * creates a new BroadcastReceiver to listen whether the Telephony State changes
 *///from  w w  w.  j  a v a2s  .  c  o  m
public void startPhoneListener() {

    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {

            @Override
            public void onReceive(final Context context, final Intent intent) {

                if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                    String state = intent.hasExtra(TelephonyManager.EXTRA_STATE)
                            ? intent.getStringExtra(TelephonyManager.EXTRA_STATE)
                            : NONE;
                    String number = "";

                    if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                        number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
                    }
                    if (callbackContext != null) {
                        final JSONObject data = new JSONObject();
                        try {
                            data.put("state", state);
                            data.put("number", number);
                        } catch (final JSONException e) {
                        }
                        ;
                        callbackContext.success(data);
                    }
                }
            }
        };

        this.context.registerReceiver(this.receiver,
                new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED));
    }
}

From source file:me.sandrin.xkcdwidget.XKCDAppWidgetProvider.java

@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    if (UPDATE.equals(intent.getAction())) {
        update(context);//from  w w  w  .  j  ava2s . c o m
    }
}