Example usage for android.content Intent toString

List of usage examples for android.content Intent toString

Introduction

In this page you can find the example usage for android.content Intent toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.maass.android.imgur_uploader.ImgurUpload.java

/**
 * //from w  w w  . j a v a  2 s .c  om
 * @return a map that contains objects with the following keys:
 * 
 *         delete - the url used to delete the uploaded image (null if
 *         error).
 * 
 *         original - the url to the uploaded image (null if error) The map
 *         is null if error
 */
private Map<String, String> handleSendIntent(final Intent intent) {
    Log.i(this.getClass().getName(), "in handleResponse()");

    Log.d(this.getClass().getName(), intent.toString());
    final Bundle extras = intent.getExtras();
    try {
        //upload a new image
        if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)
                && extras.containsKey(Intent.EXTRA_STREAM)) {

            final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            if (uri != null) {
                Log.d(this.getClass().getName(), uri.toString());
                // store uri so we can create the thumbnail if we succeed
                imageLocation = uri;
                final String jsonOutput = readPictureDataAndUpload(uri);
                return parseJSONResponse(jsonOutput);
            }
            Log.e(this.getClass().getName(), "URI null");
        }
    } catch (final Exception e) {
        Log.e(this.getClass().getName(), "Completely unexpected error", e);
    }
    return null;
}

From source file:io.clh.lrt.androidservice.TraceListenerService.java

private void traceEventStop(Context context, Intent intent) {
    JSONObject jsonData = new JSONObject();
    String appName = intent.getStringExtra("appName");
    traceEvent(context, intent);//w ww.jav  a  2 s  . co  m
    Log.d(TAG, "trace done: " + intent.toString());
    appLut.remove(appName);
}

From source file:net.niyonkuru.koodroid.service.SessionService.java

@Override
public void onHandleIntent(Intent intent) {
    if (DEBUG)/*from  w  w w . j a va  2 s. c o m*/
        Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")");

    int request = intent.getIntExtra(EXTRA_REQUEST, REQUEST_LOGIN);
    if (request == REQUEST_LOGOUT) {
        logout();
        return;
    }

    final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);

    final String email = intent.getStringExtra(EXTRA_EMAIL);
    final String password = intent.getStringExtra(EXTRA_PASSWORD);
    boolean broadcast = intent.getBooleanExtra(EXTRA_BROADCAST, false);

    /* totally ignore this request until full credentials are provided */
    if (email == null || password == null)
        return;

    final long startLogin = System.currentTimeMillis();
    final long lastLogin = mSettings.lastLogin();

    /* if the last successful login is within the last 15 minutes */
    if (startLogin - lastLogin <= DateUtils.MINUTE_IN_MILLIS * 15) {

        /* do a credentials check again the local data store */
        if (email.equals(mSettings.email()) && password.equals(mSettings.password())) {
            if (broadcast)
                IntentUtils.callWidget(this, LOGIN_FINISHED);
            announce(receiver, STATUS_FINISHED);
            return;
        }
    }

    try {
        if (NetworkUtils.isConnected(this)) {
            /* announce to the caller that we are now running */
            announce(receiver, STATUS_RUNNING);

        } else
            throw new ServiceException(getString(R.string.error_network_down));

        if (mSettings.email() == null) {
            /* this is likely a new user */
            Crittercism.leaveBreadcrumb(TAG + ": first_time_login");
        }

        login(email, password);
        saveCookies();

        if (DEBUG)
            Log.d(TAG, "login took " + (System.currentTimeMillis() - startLogin) + "ms");

    } catch (IOException e) {
        if (DEBUG)
            Log.e(TAG, "Problem while logging in", e);

        /* if the exception was simply from an abort */
        if (mPostRequest != null && mPostRequest.isAborted())
            return;

        if (receiver != null) {
            // Pass back error to surface listener
            final Bundle bundle = new Bundle();
            bundle.putString(Intent.EXTRA_TEXT, e.toString());
            receiver.send(STATUS_ERROR, bundle);
        }
        return; /* do not announce success below */
    }

    if (broadcast)
        IntentUtils.callWidget(this, LOGIN_FINISHED);
    announce(receiver, STATUS_FINISHED);
}

From source file:org.ounl.lifelonglearninghub.mediaplayer.cast.refplayer.NFCVideoBrowserActivity.java

/**
 * On create, process NDEF message with its intent action
 *  /*from   w w w .j  ava 2 s .  co m*/
 * @param intent
 */
private String resolveIntent(Intent intent) {
    Log.d(CLASSNAME, "resolveIntent is called intent:" + intent.toString());
    String action = intent.getAction();
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)
            || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage[] msgs;
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
            }
        } else {
            // Unknown tag type
            byte[] empty = new byte[0];
            byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
            Parcelable tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
            byte[] payload = dumpTagData(tag).getBytes();
            NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, id, payload);
            NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
            msgs = new NdefMessage[] { msg };
        }

        return processNdefMessageArray(msgs);

    }

    return IParsedNdefCommand.COMMAND_UNKNOWN;
}

From source file:com.java2s.intents4.IntentsDemo4Activity.java

void finishTest(Intent intent) {
    Log.i(CLASSNAME, "---------");
    Log.i(CLASSNAME, intent.toString());
    filter = createFilterFromEditTextFields();

    filterToString(filter);/*w w  w  .j a  v a2 s .c  o m*/

    try {
        unregisterReceiver(myReceiver);
    } catch (IllegalArgumentException e) {
        // Do nothing
    }
    registerReceiver(myReceiver, filter);

    messagesView.setText(intent.toString() + "\n\n" + filterToString(filter));
    sendBroadcast(intent);

    Log.i(CLASSNAME, "---------");
}

From source file:com.waz.zclient.pages.main.conversation.AssetIntentsManager.java

private void openDocument(String mimeType, IntentType tpe) {
    if (BuildConfig.IS_TEST_GALLERY_ALLOWED) {
        // trying to load file from testing gallery,
        // this is needed because we are not able to override DocumentsUI on some android versions.
        Intent intent = new Intent("com.wire.testing.GET_DOCUMENT").setType(mimeType);
        if (!pm.queryIntentActivities(intent, PackageManager.MATCH_ALL).isEmpty()) {
            callback.openIntent(intent, tpe);
            return;
        }/*from  www.j  a  va2 s  .c  o m*/
        Timber.i("Did not resolve testing gallery for intent: %s", intent.toString());
    }
    callback.openIntent(
            new Intent(openDocumentAction()).setType(mimeType).addCategory(Intent.CATEGORY_OPENABLE), tpe);
}

From source file:com.google.android.apps.dashclock.DashClockService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGD(TAG, "onStartCommand: " + (intent != null ? intent.toString() : "no intent"));
    enforceCallingPermission(DashClockExtension.PERMISSION_READ_EXTENSION_DATA);

    if (intent != null) {
        String action = intent.getAction();
        if (ACTION_UPDATE_WIDGETS.equals(action)) {
            handleUpdateWidgets(intent);

        } else if (ACTION_UPDATE_EXTENSIONS.equals(action)) {
            handleUpdateExtensions(intent);
        }//from www  .  ja v a  2  s.co m

        // If started by a wakeful broadcast receiver, release the wake lock it acquired.
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }

    return START_STICKY;
}

From source file:com.embeddedlog.LightUpDroid.timer.TimerReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (Timers.LOGGING) {
        Log.v(TAG, "Received intent " + intent.toString());
    }/*w w  w .  j  av a2 s .  co m*/
    String actionType = intent.getAction();
    // This action does not need the timers data
    if (Timers.NOTIF_IN_USE_CANCEL.equals(actionType)) {
        cancelInUseNotification(context);
        return;
    }

    // Get the updated timers data.
    if (mTimers == null) {
        mTimers = new ArrayList<TimerObj>();
    }
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    TimerObj.getTimersFromSharedPrefs(prefs, mTimers);

    // These actions do not provide a timer ID, but do use the timers data
    if (Timers.NOTIF_IN_USE_SHOW.equals(actionType)) {
        showInUseNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_SHOW.equals(actionType)) {
        showTimesUpNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_CANCEL.equals(actionType)) {
        cancelTimesUpNotification(context);
        return;
    }

    // Remaining actions provide a timer Id
    if (!intent.hasExtra(Timers.TIMER_INTENT_EXTRA)) {
        // No data to work with, do nothing
        Log.e(TAG, "got intent without Timer data");
        return;
    }

    // Get the timer out of the Intent
    int timerId = intent.getIntExtra(Timers.TIMER_INTENT_EXTRA, -1);
    if (timerId == -1) {
        Log.d(TAG, "OnReceive:intent without Timer data for " + actionType);
    }

    TimerObj t = Timers.findTimer(mTimers, timerId);

    if (Timers.TIMES_UP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, " timer not found in list - do nothing");
            return;
        }

        t.mState = TimerObj.STATE_TIMESUP;
        t.writeToSharedPref(prefs);
        // Play ringtone by using TimerRingService service with a default alarm.
        Log.d(TAG, "playing ringtone");
        Intent si = new Intent();
        si.setClass(context, TimerRingService.class);
        context.startService(si);

        // Update the in-use notification
        if (getNextRunningTimer(mTimers, false, Utils.getTimeNow()) == null) {
            // Found no running timers.
            cancelInUseNotification(context);
        } else {
            showInUseNotification(context);
        }

        // Start the TimerAlertFullScreen activity.
        Intent timersAlert = new Intent(context, TimerAlertFullScreen.class);
        timersAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
        context.startActivity(timersAlert);
    } else if (Timers.TIMER_RESET.equals(actionType) || Timers.DELETE_TIMER.equals(actionType)
            || Timers.TIMER_DONE.equals(actionType)) {
        // Stop Ringtone if all timers are not in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_STOP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, "timer to stop not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(TAG, "action to stop but timer not in times-up state - do nothing");
            return;
        }

        // Update timer state
        t.mState = t.getDeleteAfterUse() ? TimerObj.STATE_DELETED : TimerObj.STATE_DONE;
        t.mTimeLeft = t.mOriginalLength - (Utils.getTimeNow() - t.mStartTime);
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // Done with timer - delete from data base
        if (t.getDeleteAfterUse()) {
            t.deleteFromSharedPref(prefs);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, "timer to +1m not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(TAG, "action to +1m but timer not in times up state - do nothing");
            return;
        }

        // Restarting the timer with 1 minute left.
        t.mState = TimerObj.STATE_RUNNING;
        t.mStartTime = Utils.getTimeNow();
        t.mTimeLeft = t.mOriginalLength = TimerObj.MINUTE_IN_MILLIS;
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // If the app is not open, refresh the in-use notification
        if (!prefs.getBoolean(Timers.NOTIF_APP_OPEN, false)) {
            showInUseNotification(context);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.TIMER_UPDATE.equals(actionType)) {
        // Refresh buzzing notification
        if (t.mState == TimerObj.STATE_TIMESUP) {
            // Must cancel the previous notification to get all updates displayed correctly
            cancelTimesUpNotification(context, t);
            showTimesUpNotification(context, t);
        }
    }
    // Update the next "Times up" alarm
    updateNextTimesup(context);
}

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

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("request code", requestCode + "");
    if (resultCode == -1)
        Log.d("intent", data.toString());
    if (requestCode == 3 && resultCode == -1) {
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.setAction("com.krayzk9s.imgurholo.services.UploadService");
        serviceIntent.setData(data.getData());
        startService(serviceIntent);//from   w w w  .j a  v  a  2 s.c o m
        return;
    }
    if (requestCode == 4 && resultCode == -1) {
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        if (data.getExtras() != null)
            Log.d("intent extras", data.getExtras().toString());
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.setAction("com.krayzk9s.imgurholo.services.UploadService");
        serviceIntent.setData(data.getData());
        startService(serviceIntent);
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:se.oort.clockify.timer.TimerReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (Timers.LOGGING) {
        Log.v(LOG_TAG, "Received intent " + intent.toString());
    }/*from  www . j  a  v a 2 s.  co m*/
    String actionType = intent.getAction();
    // This action does not need the timers data
    if (Timers.NOTIF_IN_USE_CANCEL.equals(actionType)) {
        cancelInUseNotification(context);
        return;
    }

    // Get the updated timers data.
    if (mTimers == null) {
        mTimers = new ArrayList<TimerObj>();
    }
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    TimerObj.getTimersFromSharedPrefs(prefs, mTimers);

    // These actions do not provide a timer ID, but do use the timers data
    if (Timers.NOTIF_IN_USE_SHOW.equals(actionType)) {
        showInUseNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_SHOW.equals(actionType)) {
        showTimesUpNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_CANCEL.equals(actionType)) {
        cancelTimesUpNotification(context);
        return;
    }

    // Remaining actions provide a timer Id
    if (!intent.hasExtra(Timers.TIMER_INTENT_EXTRA)) {
        // No data to work with, do nothing
        Log.e(LOG_TAG, "got intent without Timer data");
        return;
    }

    // Get the timer out of the Intent
    int timerId = intent.getIntExtra(Timers.TIMER_INTENT_EXTRA, -1);
    if (timerId == -1) {
        Log.d(LOG_TAG, "OnReceive:intent without Timer data for " + actionType);
    }

    TimerObj t = Timers.findTimer(mTimers, timerId);

    if (Timers.TIMES_UP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, " timer not found in list - do nothing");
            return;
        }

        t.mState = TimerObj.STATE_TIMESUP;
        t.writeToSharedPref(prefs);
        // Play ringtone by using TimerRingService service with a default alarm.
        Log.d(LOG_TAG, "playing ringtone");
        Intent si = new Intent();
        si.setClass(context, TimerRingService.class);
        context.startService(si);

        // Update the in-use notification
        if (getNextRunningTimer(mTimers, false, Utils.getTimeNow()) == null) {
            // Found no running timers.
            cancelInUseNotification(context);
        } else {
            showInUseNotification(context);
        }

        // Start the TimerAlertFullScreen activity.
        Intent timersAlert = new Intent(context, TimerAlertFullScreen.class);
        timersAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
        context.startActivity(timersAlert);
    } else if (Timers.TIMER_RESET.equals(actionType) || Timers.DELETE_TIMER.equals(actionType)
            || Timers.TIMER_DONE.equals(actionType)) {
        // Stop Ringtone if all timers are not in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_STOP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, "timer to stop not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(LOG_TAG, "action to stop but timer not in times-up state - do nothing");
            return;
        }

        // Update timer state
        t.mState = t.getDeleteAfterUse() ? TimerObj.STATE_DELETED : TimerObj.STATE_DONE;
        t.mTimeLeft = t.mOriginalLength - (Utils.getTimeNow() - t.mStartTime);
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // Done with timer - delete from data base
        if (t.getDeleteAfterUse()) {
            t.deleteFromSharedPref(prefs);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, "timer to +1m not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(LOG_TAG, "action to +1m but timer not in times up state - do nothing");
            return;
        }

        // Restarting the timer with 1 minute left.
        t.mState = TimerObj.STATE_RUNNING;
        t.mStartTime = Utils.getTimeNow();
        t.mTimeLeft = t.mOriginalLength = TimerObj.MINUTE_IN_MILLIS;
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // If the app is not open, refresh the in-use notification
        if (!prefs.getBoolean(Timers.NOTIF_APP_OPEN, false)) {
            showInUseNotification(context);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.TIMER_UPDATE.equals(actionType)) {
        // Refresh buzzing notification
        if (t.mState == TimerObj.STATE_TIMESUP) {
            // Must cancel the previous notification to get all updates displayed correctly
            cancelTimesUpNotification(context, t);
            showTimesUpNotification(context, t);
        }
    }
    // Update the next "Times up" alarm
    updateNextTimesup(context);
}