Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.piusvelte.sonet.core.SonetService.java

private void start(Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        Log.d(TAG, "action:" + action);
        if (ACTION_REFRESH.equals(action)) {
            if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS))
                putValidatedUpdates(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), 1);
            else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID))
                putValidatedUpdates(new int[] { intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID) }, 1);
            else if (intent.getData() != null)
                putValidatedUpdates(new int[] { Integer.parseInt(intent.getData().getLastPathSegment()) }, 1);
            else/*from   ww w .  j a  v a2s  . c o m*/
                putValidatedUpdates(null, 0);
        } else if (LauncherIntent.Action.ACTION_READY.equals(action)) {
            if (intent.hasExtra(EXTRA_SCROLLABLE_VERSION)
                    && intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                int scrollableVersion = intent.getIntExtra(EXTRA_SCROLLABLE_VERSION, 1);
                int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID);
                // check if the scrollable needs to be built
                Cursor widget = this.getContentResolver().query(Widgets.getContentUri(SonetService.this),
                        new String[] { Widgets._ID, Widgets.SCROLLABLE }, Widgets.WIDGET + "=?",
                        new String[] { Integer.toString(appWidgetId) }, null);
                if (widget.moveToFirst()) {
                    if (widget.getInt(widget.getColumnIndex(Widgets.SCROLLABLE)) < scrollableVersion) {
                        ContentValues values = new ContentValues();
                        values.put(Widgets.SCROLLABLE, scrollableVersion);
                        // set the scrollable version
                        this.getContentResolver().update(Widgets.getContentUri(SonetService.this), values,
                                Widgets.WIDGET + "=?", new String[] { Integer.toString(appWidgetId) });
                        putValidatedUpdates(new int[] { appWidgetId }, 1);
                    } else
                        putValidatedUpdates(new int[] { appWidgetId }, 1);
                } else {
                    ContentValues values = new ContentValues();
                    values.put(Widgets.SCROLLABLE, scrollableVersion);
                    // set the scrollable version
                    this.getContentResolver().update(Widgets.getContentUri(SonetService.this), values,
                            Widgets.WIDGET + "=?", new String[] { Integer.toString(appWidgetId) });
                    putValidatedUpdates(new int[] { appWidgetId }, 1);
                }
                widget.close();
            } else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                // requery
                putValidatedUpdates(new int[] { intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID) }, 0);
            }
        } else if (SMS_RECEIVED.equals(action)) {
            // parse the sms, and notify any widgets which have sms enabled
            Bundle bundle = intent.getExtras();
            Object[] pdus = (Object[]) bundle.get("pdus");
            for (int i = 0; i < pdus.length; i++) {
                SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
                AsyncTask<SmsMessage, String, int[]> smsLoader = new AsyncTask<SmsMessage, String, int[]>() {

                    @Override
                    protected int[] doInBackground(SmsMessage... msg) {
                        // check if SMS is enabled anywhere
                        Cursor widgets = getContentResolver().query(
                                Widget_accounts_view.getContentUri(SonetService.this),
                                new String[] { Widget_accounts_view._ID, Widget_accounts_view.WIDGET,
                                        Widget_accounts_view.ACCOUNT },
                                Widget_accounts_view.SERVICE + "=?", new String[] { Integer.toString(SMS) },
                                null);
                        int[] appWidgetIds = new int[widgets.getCount()];
                        if (widgets.moveToFirst()) {
                            // insert this message to the statuses db and requery scrollable/rebuild widget
                            // check if this is a contact
                            String phone = msg[0].getOriginatingAddress();
                            String friend = phone;
                            byte[] profile = null;
                            Uri content_uri = null;
                            // unknown numbers crash here in the emulator
                            Cursor phones = getContentResolver().query(
                                    Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
                                            Uri.encode(phone)),
                                    new String[] { ContactsContract.PhoneLookup._ID }, null, null, null);
                            if (phones.moveToFirst())
                                content_uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,
                                        phones.getLong(0));
                            else {
                                Cursor emails = getContentResolver().query(
                                        Uri.withAppendedPath(
                                                ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI,
                                                Uri.encode(phone)),
                                        new String[] { ContactsContract.CommonDataKinds.Email._ID }, null, null,
                                        null);
                                if (emails.moveToFirst())
                                    content_uri = ContentUris.withAppendedId(
                                            ContactsContract.Contacts.CONTENT_URI, emails.getLong(0));
                                emails.close();
                            }
                            phones.close();
                            if (content_uri != null) {
                                // load contact
                                Cursor contacts = getContentResolver().query(content_uri,
                                        new String[] { ContactsContract.Contacts.DISPLAY_NAME }, null, null,
                                        null);
                                if (contacts.moveToFirst())
                                    friend = contacts.getString(0);
                                contacts.close();
                                profile = getBlob(ContactsContract.Contacts
                                        .openContactPhotoInputStream(getContentResolver(), content_uri));
                            }
                            long accountId = widgets.getLong(2);
                            long id;
                            ContentValues values = new ContentValues();
                            values.put(Entities.ESID, phone);
                            values.put(Entities.FRIEND, friend);
                            values.put(Entities.PROFILE, profile);
                            values.put(Entities.ACCOUNT, accountId);
                            Cursor entity = getContentResolver().query(
                                    Entities.getContentUri(SonetService.this), new String[] { Entities._ID },
                                    Entities.ACCOUNT + "=? and " + Entities.ESID + "=?",
                                    new String[] { Long.toString(accountId), mSonetCrypto.Encrypt(phone) },
                                    null);
                            if (entity.moveToFirst()) {
                                id = entity.getLong(0);
                                getContentResolver().update(Entities.getContentUri(SonetService.this), values,
                                        Entities._ID + "=?", new String[] { Long.toString(id) });
                            } else
                                id = Long.parseLong(getContentResolver()
                                        .insert(Entities.getContentUri(SonetService.this), values)
                                        .getLastPathSegment());
                            entity.close();
                            values.clear();
                            Long created = msg[0].getTimestampMillis();
                            values.put(Statuses.CREATED, created);
                            values.put(Statuses.ENTITY, id);
                            values.put(Statuses.MESSAGE, msg[0].getMessageBody());
                            values.put(Statuses.SERVICE, SMS);
                            while (!widgets.isAfterLast()) {
                                int widget = widgets.getInt(1);
                                appWidgetIds[widgets.getPosition()] = widget;
                                // get settings
                                boolean time24hr = true;
                                int status_bg_color = Sonet.default_message_bg_color;
                                int profile_bg_color = Sonet.default_message_bg_color;
                                int friend_bg_color = Sonet.default_friend_bg_color;
                                boolean icon = true;
                                int status_count = Sonet.default_statuses_per_account;
                                int notifications = 0;
                                Cursor c = getContentResolver().query(
                                        Widgets_settings.getContentUri(SonetService.this),
                                        new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT, Widgets.SOUND,
                                                Widgets.VIBRATE, Widgets.LIGHTS, Widgets.PROFILES_BG_COLOR,
                                                Widgets.FRIEND_BG_COLOR },
                                        Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                        new String[] { Integer.toString(widget), Long.toString(accountId) },
                                        null);
                                if (!c.moveToFirst()) {
                                    c.close();
                                    c = getContentResolver().query(
                                            Widgets_settings.getContentUri(SonetService.this),
                                            new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                    Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT, Widgets.SOUND,
                                                    Widgets.VIBRATE, Widgets.LIGHTS, Widgets.PROFILES_BG_COLOR,
                                                    Widgets.FRIEND_BG_COLOR },
                                            Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                            new String[] { Integer.toString(widget),
                                                    Long.toString(Sonet.INVALID_ACCOUNT_ID) },
                                            null);
                                    if (!c.moveToFirst()) {
                                        c.close();
                                        c = getContentResolver().query(
                                                Widgets_settings.getContentUri(SonetService.this),
                                                new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                        Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT,
                                                        Widgets.SOUND, Widgets.VIBRATE, Widgets.LIGHTS,
                                                        Widgets.PROFILES_BG_COLOR, Widgets.FRIEND_BG_COLOR },
                                                Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                                new String[] {
                                                        Integer.toString(AppWidgetManager.INVALID_APPWIDGET_ID),
                                                        Long.toString(Sonet.INVALID_ACCOUNT_ID) },
                                                null);
                                        if (!c.moveToFirst())
                                            initAccountSettings(SonetService.this,
                                                    AppWidgetManager.INVALID_APPWIDGET_ID,
                                                    Sonet.INVALID_ACCOUNT_ID);
                                        if (widget != AppWidgetManager.INVALID_APPWIDGET_ID)
                                            initAccountSettings(SonetService.this, widget,
                                                    Sonet.INVALID_ACCOUNT_ID);
                                    }
                                    initAccountSettings(SonetService.this, widget, accountId);
                                }
                                if (c.moveToFirst()) {
                                    time24hr = c.getInt(0) == 1;
                                    status_bg_color = c.getInt(1);
                                    icon = c.getInt(2) == 1;
                                    status_count = c.getInt(3);
                                    if (c.getInt(4) == 1)
                                        notifications |= Notification.DEFAULT_SOUND;
                                    if (c.getInt(5) == 1)
                                        notifications |= Notification.DEFAULT_VIBRATE;
                                    if (c.getInt(6) == 1)
                                        notifications |= Notification.DEFAULT_LIGHTS;
                                    profile_bg_color = c.getInt(7);
                                    friend_bg_color = c.getInt(8);
                                }
                                c.close();
                                values.put(Statuses.CREATEDTEXT, Sonet.getCreatedText(created, time24hr));
                                // update the bg and icon
                                // create the status_bg
                                values.put(Statuses.STATUS_BG, createBackground(status_bg_color));
                                // friend_bg
                                values.put(Statuses.FRIEND_BG, createBackground(friend_bg_color));
                                // profile_bg
                                values.put(Statuses.PROFILE_BG, createBackground(profile_bg_color));
                                values.put(Statuses.ICON,
                                        icon ? getBlob(getResources(), map_icons[SMS]) : null);
                                // insert the message
                                values.put(Statuses.WIDGET, widget);
                                values.put(Statuses.ACCOUNT, accountId);
                                getContentResolver().insert(Statuses.getContentUri(SonetService.this), values);
                                // check the status count, removing old sms
                                Cursor statuses = getContentResolver().query(
                                        Statuses.getContentUri(SonetService.this),
                                        new String[] { Statuses._ID },
                                        Statuses.WIDGET + "=? and " + Statuses.ACCOUNT + "=?",
                                        new String[] { Integer.toString(widget), Long.toString(accountId) },
                                        Statuses.CREATED + " desc");
                                if (statuses.moveToFirst()) {
                                    while (!statuses.isAfterLast()) {
                                        if (statuses.getPosition() >= status_count) {
                                            getContentResolver().delete(
                                                    Statuses.getContentUri(SonetService.this),
                                                    Statuses._ID + "=?", new String[] { Long.toString(statuses
                                                            .getLong(statuses.getColumnIndex(Statuses._ID))) });
                                        }
                                        statuses.moveToNext();
                                    }
                                }
                                statuses.close();
                                if (notifications != 0)
                                    publishProgress(Integer.toString(notifications),
                                            friend + " sent a message");
                                widgets.moveToNext();
                            }
                        }
                        widgets.close();
                        return appWidgetIds;
                    }

                    @Override
                    protected void onProgressUpdate(String... updates) {
                        int notifications = Integer.parseInt(updates[0]);
                        if (notifications != 0) {
                            Notification notification = new Notification(R.drawable.notification, updates[1],
                                    System.currentTimeMillis());
                            notification.setLatestEventInfo(getBaseContext(), "New messages", updates[1],
                                    PendingIntent.getActivity(SonetService.this, 0, (Sonet
                                            .getPackageIntent(SonetService.this, SonetNotifications.class)),
                                            0));
                            notification.defaults |= notifications;
                            ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
                                    .notify(NOTIFY_ID, notification);
                        }
                    }

                    @Override
                    protected void onPostExecute(int[] appWidgetIds) {
                        // remove self from thread list
                        if (!mSMSLoaders.isEmpty())
                            mSMSLoaders.remove(this);
                        putValidatedUpdates(appWidgetIds, 0);
                    }

                };
                mSMSLoaders.add(smsLoader);
                smsLoader.execute(msg);
            }
        } else if (ACTION_PAGE_DOWN.equals(action))
            (new PagingTask()).execute(Integer.parseInt(intent.getData().getLastPathSegment()),
                    intent.getIntExtra(ACTION_PAGE_DOWN, 0));
        else if (ACTION_PAGE_UP.equals(action))
            (new PagingTask()).execute(Integer.parseInt(intent.getData().getLastPathSegment()),
                    intent.getIntExtra(ACTION_PAGE_UP, 0));
        else {
            // this might be a widget update from the widget refresh button
            int appWidgetId;
            try {
                appWidgetId = Integer.parseInt(action);
                putValidatedUpdates(new int[] { appWidgetId }, 1);
            } catch (NumberFormatException e) {
                Log.d(TAG, "unknown action:" + action);
            }
        }
    }
}

From source file:com.geotrackin.gpslogger.GpsLoggingService.java

private void HandleIntent(Intent intent) {

    tracer.debug(".");
    GetPreferences();//from   w w  w. ja va  2 s .c  o m

    if (intent != null) {
        Bundle bundle = intent.getExtras();

        if (bundle != null) {
            boolean needToStartGpsManager = false;

            boolean stopRightNow = bundle.getBoolean("immediatestop");
            boolean startRightNow = bundle.getBoolean("immediatestart");
            boolean sendEmailNow = bundle.getBoolean("emailAlarm");
            boolean getNextPoint = bundle.getBoolean("getnextpoint");

            tracer.debug("stopRightNow - " + String.valueOf(stopRightNow) + ", startRightNow - "
                    + String.valueOf(startRightNow) + ", sendEmailNow - " + String.valueOf(sendEmailNow)
                    + ", getNextPoint - " + String.valueOf(getNextPoint));

            if (startRightNow) {
                tracer.info("Intent received - Start Logging Now");
                StartLogging();
            }

            if (stopRightNow) {
                tracer.info("Intent received - Stop logging now");
                StopLogging();
            }

            if (sendEmailNow) {

                tracer.debug("Intent received - Send Email Now");

                Session.setReadyToBeAutoSent(true);
                AutoSendLogFile();
            }

            if (getNextPoint) {
                tracer.debug("Intent received - Get Next Point");
                needToStartGpsManager = true;
            }

            String setNextPointDescription = bundle.getString("setnextpointdescription");
            if (setNextPointDescription != null) {
                tracer.debug("Intent received - Set Next Point Description: " + setNextPointDescription);

                final String desc = Utilities.CleanDescription(setNextPointDescription);
                if (desc.length() == 0) {
                    tracer.debug("Clearing annotation");
                    Session.clearDescription();
                } else {
                    tracer.debug("Setting annotation: " + desc);
                    Session.setDescription(desc);
                }
                needToStartGpsManager = true;
            }

            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

            if (bundle.get("setprefercelltower") != null) {
                boolean preferCellTower = bundle.getBoolean("setprefercelltower");
                tracer.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower));
                prefs.edit().putBoolean("prefer_celltower", preferCellTower).commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("settimebeforelogging") != null) {
                int timeBeforeLogging = bundle.getInt("settimebeforelogging");
                tracer.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging));
                prefs.edit().putString("time_before_logging", String.valueOf(timeBeforeLogging)).commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("setdistancebeforelogging") != null) {
                int distanceBeforeLogging = bundle.getInt("setdistancebeforelogging");
                tracer.debug("Intent received - Set Distance Before Logging: "
                        + String.valueOf(distanceBeforeLogging));
                prefs.edit().putString("distance_before_logging", String.valueOf(distanceBeforeLogging))
                        .commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("setkeepbetweenfix") != null) {
                boolean keepBetweenFix = bundle.getBoolean("setkeepbetweenfix");
                tracer.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix));
                prefs.edit().putBoolean("keep_fix", keepBetweenFix).commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("setretrytime") != null) {
                int retryTime = bundle.getInt("setretrytime");
                tracer.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime));
                prefs.edit().putString("retry_time", String.valueOf(retryTime)).commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("setabsolutetimeout") != null) {
                int absolumeTimeOut = bundle.getInt("setabsolutetimeout");
                tracer.debug("Intent received - Set Retry Time: " + String.valueOf(absolumeTimeOut));
                prefs.edit().putString("absolute_timeout", String.valueOf(absolumeTimeOut)).commit();
                needToStartGpsManager = true;
            }

            if (bundle.get("logonce") != null) {
                boolean logOnceIntent = bundle.getBoolean("logonce");
                tracer.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent));
                needToStartGpsManager = false;
                LogOnce();
            }

            if (needToStartGpsManager && Session.isStarted()) {
                StartGpsManager();
            }
        }
    } else {
        // A null intent is passed in if the service has been killed and
        // restarted.
        tracer.debug("Service restarted with null intent. Start logging.");
        StartLogging();

    }
}

From source file:com.shafiq.myfeedle.core.MyfeedleService.java

private void start(Intent intent) {
    if (intent != null) {
        String action = intent.getAction();
        Log.d(TAG, "action:" + action);
        if (ACTION_REFRESH.equals(action)) {
            if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS))
                putValidatedUpdates(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), 1);
            else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID))
                putValidatedUpdates(new int[] { intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID) }, 1);
            else if (intent.getData() != null)
                putValidatedUpdates(new int[] { Integer.parseInt(intent.getData().getLastPathSegment()) }, 1);
            else/*from   www .ja  va 2 s . c  om*/
                putValidatedUpdates(null, 0);
        } else if (LauncherIntent.Action.ACTION_READY.equals(action)) {
            if (intent.hasExtra(EXTRA_SCROLLABLE_VERSION)
                    && intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                int scrollableVersion = intent.getIntExtra(EXTRA_SCROLLABLE_VERSION, 1);
                int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID);
                // check if the scrollable needs to be built
                Cursor widget = this.getContentResolver().query(Widgets.getContentUri(MyfeedleService.this),
                        new String[] { Widgets._ID, Widgets.SCROLLABLE }, Widgets.WIDGET + "=?",
                        new String[] { Integer.toString(appWidgetId) }, null);
                if (widget.moveToFirst()) {
                    if (widget.getInt(widget.getColumnIndex(Widgets.SCROLLABLE)) < scrollableVersion) {
                        ContentValues values = new ContentValues();
                        values.put(Widgets.SCROLLABLE, scrollableVersion);
                        // set the scrollable version
                        this.getContentResolver().update(Widgets.getContentUri(MyfeedleService.this), values,
                                Widgets.WIDGET + "=?", new String[] { Integer.toString(appWidgetId) });
                        putValidatedUpdates(new int[] { appWidgetId }, 1);
                    } else
                        putValidatedUpdates(new int[] { appWidgetId }, 1);
                } else {
                    ContentValues values = new ContentValues();
                    values.put(Widgets.SCROLLABLE, scrollableVersion);
                    // set the scrollable version
                    this.getContentResolver().update(Widgets.getContentUri(MyfeedleService.this), values,
                            Widgets.WIDGET + "=?", new String[] { Integer.toString(appWidgetId) });
                    putValidatedUpdates(new int[] { appWidgetId }, 1);
                }
                widget.close();
            } else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                // requery
                putValidatedUpdates(new int[] { intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        AppWidgetManager.INVALID_APPWIDGET_ID) }, 0);
            }
        } else if (SMS_RECEIVED.equals(action)) {
            // parse the sms, and notify any widgets which have sms enabled
            Bundle bundle = intent.getExtras();
            Object[] pdus = (Object[]) bundle.get("pdus");
            for (int i = 0; i < pdus.length; i++) {
                SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
                AsyncTask<SmsMessage, String, int[]> smsLoader = new AsyncTask<SmsMessage, String, int[]>() {

                    @Override
                    protected int[] doInBackground(SmsMessage... msg) {
                        // check if SMS is enabled anywhere
                        Cursor widgets = getContentResolver().query(
                                Widget_accounts_view.getContentUri(MyfeedleService.this),
                                new String[] { Widget_accounts_view._ID, Widget_accounts_view.WIDGET,
                                        Widget_accounts_view.ACCOUNT },
                                Widget_accounts_view.SERVICE + "=?", new String[] { Integer.toString(SMS) },
                                null);
                        int[] appWidgetIds = new int[widgets.getCount()];
                        if (widgets.moveToFirst()) {
                            // insert this message to the statuses db and requery scrollable/rebuild widget
                            // check if this is a contact
                            String phone = msg[0].getOriginatingAddress();
                            String friend = phone;
                            byte[] profile = null;
                            Uri content_uri = null;
                            // unknown numbers crash here in the emulator
                            Cursor phones = getContentResolver().query(
                                    Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
                                            Uri.encode(phone)),
                                    new String[] { ContactsContract.PhoneLookup._ID }, null, null, null);
                            if (phones.moveToFirst())
                                content_uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,
                                        phones.getLong(0));
                            else {
                                Cursor emails = getContentResolver().query(
                                        Uri.withAppendedPath(
                                                ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI,
                                                Uri.encode(phone)),
                                        new String[] { ContactsContract.CommonDataKinds.Email._ID }, null, null,
                                        null);
                                if (emails.moveToFirst())
                                    content_uri = ContentUris.withAppendedId(
                                            ContactsContract.Contacts.CONTENT_URI, emails.getLong(0));
                                emails.close();
                            }
                            phones.close();
                            if (content_uri != null) {
                                // load contact
                                Cursor contacts = getContentResolver().query(content_uri,
                                        new String[] { ContactsContract.Contacts.DISPLAY_NAME }, null, null,
                                        null);
                                if (contacts.moveToFirst())
                                    friend = contacts.getString(0);
                                contacts.close();
                                profile = getBlob(ContactsContract.Contacts
                                        .openContactPhotoInputStream(getContentResolver(), content_uri));
                            }
                            long accountId = widgets.getLong(2);
                            long id;
                            ContentValues values = new ContentValues();
                            values.put(Entities.ESID, phone);
                            values.put(Entities.FRIEND, friend);
                            values.put(Entities.PROFILE, profile);
                            values.put(Entities.ACCOUNT, accountId);
                            Cursor entity = getContentResolver().query(
                                    Entities.getContentUri(MyfeedleService.this), new String[] { Entities._ID },
                                    Entities.ACCOUNT + "=? and " + Entities.ESID + "=?",
                                    new String[] { Long.toString(accountId), mMyfeedleCrypto.Encrypt(phone) },
                                    null);
                            if (entity.moveToFirst()) {
                                id = entity.getLong(0);
                                getContentResolver().update(Entities.getContentUri(MyfeedleService.this),
                                        values, Entities._ID + "=?", new String[] { Long.toString(id) });
                            } else
                                id = Long.parseLong(getContentResolver()
                                        .insert(Entities.getContentUri(MyfeedleService.this), values)
                                        .getLastPathSegment());
                            entity.close();
                            values.clear();
                            Long created = msg[0].getTimestampMillis();
                            values.put(Statuses.CREATED, created);
                            values.put(Statuses.ENTITY, id);
                            values.put(Statuses.MESSAGE, msg[0].getMessageBody());
                            values.put(Statuses.SERVICE, SMS);
                            while (!widgets.isAfterLast()) {
                                int widget = widgets.getInt(1);
                                appWidgetIds[widgets.getPosition()] = widget;
                                // get settings
                                boolean time24hr = true;
                                int status_bg_color = Myfeedle.default_message_bg_color;
                                int profile_bg_color = Myfeedle.default_message_bg_color;
                                int friend_bg_color = Myfeedle.default_friend_bg_color;
                                boolean icon = true;
                                int status_count = Myfeedle.default_statuses_per_account;
                                int notifications = 0;
                                Cursor c = getContentResolver().query(
                                        Widgets_settings.getContentUri(MyfeedleService.this),
                                        new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT, Widgets.SOUND,
                                                Widgets.VIBRATE, Widgets.LIGHTS, Widgets.PROFILES_BG_COLOR,
                                                Widgets.FRIEND_BG_COLOR },
                                        Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                        new String[] { Integer.toString(widget), Long.toString(accountId) },
                                        null);
                                if (!c.moveToFirst()) {
                                    c.close();
                                    c = getContentResolver().query(
                                            Widgets_settings.getContentUri(MyfeedleService.this),
                                            new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                    Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT, Widgets.SOUND,
                                                    Widgets.VIBRATE, Widgets.LIGHTS, Widgets.PROFILES_BG_COLOR,
                                                    Widgets.FRIEND_BG_COLOR },
                                            Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                            new String[] { Integer.toString(widget),
                                                    Long.toString(Myfeedle.INVALID_ACCOUNT_ID) },
                                            null);
                                    if (!c.moveToFirst()) {
                                        c.close();
                                        c = getContentResolver().query(
                                                Widgets_settings.getContentUri(MyfeedleService.this),
                                                new String[] { Widgets.TIME24HR, Widgets.MESSAGES_BG_COLOR,
                                                        Widgets.ICON, Widgets.STATUSES_PER_ACCOUNT,
                                                        Widgets.SOUND, Widgets.VIBRATE, Widgets.LIGHTS,
                                                        Widgets.PROFILES_BG_COLOR, Widgets.FRIEND_BG_COLOR },
                                                Widgets.WIDGET + "=? and " + Widgets.ACCOUNT + "=?",
                                                new String[] {
                                                        Integer.toString(AppWidgetManager.INVALID_APPWIDGET_ID),
                                                        Long.toString(Myfeedle.INVALID_ACCOUNT_ID) },
                                                null);
                                        if (!c.moveToFirst())
                                            initAccountSettings(MyfeedleService.this,
                                                    AppWidgetManager.INVALID_APPWIDGET_ID,
                                                    Myfeedle.INVALID_ACCOUNT_ID);
                                        if (widget != AppWidgetManager.INVALID_APPWIDGET_ID)
                                            initAccountSettings(MyfeedleService.this, widget,
                                                    Myfeedle.INVALID_ACCOUNT_ID);
                                    }
                                    initAccountSettings(MyfeedleService.this, widget, accountId);
                                }
                                if (c.moveToFirst()) {
                                    time24hr = c.getInt(0) == 1;
                                    status_bg_color = c.getInt(1);
                                    icon = c.getInt(2) == 1;
                                    status_count = c.getInt(3);
                                    if (c.getInt(4) == 1)
                                        notifications |= Notification.DEFAULT_SOUND;
                                    if (c.getInt(5) == 1)
                                        notifications |= Notification.DEFAULT_VIBRATE;
                                    if (c.getInt(6) == 1)
                                        notifications |= Notification.DEFAULT_LIGHTS;
                                    profile_bg_color = c.getInt(7);
                                    friend_bg_color = c.getInt(8);
                                }
                                c.close();
                                values.put(Statuses.CREATEDTEXT, Myfeedle.getCreatedText(created, time24hr));
                                // update the bg and icon
                                // create the status_bg
                                values.put(Statuses.STATUS_BG, createBackground(status_bg_color));
                                // friend_bg
                                values.put(Statuses.FRIEND_BG, createBackground(friend_bg_color));
                                // profile_bg
                                values.put(Statuses.PROFILE_BG, createBackground(profile_bg_color));
                                values.put(Statuses.ICON,
                                        icon ? getBlob(getResources(), map_icons[SMS]) : null);
                                // insert the message
                                values.put(Statuses.WIDGET, widget);
                                values.put(Statuses.ACCOUNT, accountId);
                                getContentResolver().insert(Statuses.getContentUri(MyfeedleService.this),
                                        values);
                                // check the status count, removing old sms
                                Cursor statuses = getContentResolver().query(
                                        Statuses.getContentUri(MyfeedleService.this),
                                        new String[] { Statuses._ID },
                                        Statuses.WIDGET + "=? and " + Statuses.ACCOUNT + "=?",
                                        new String[] { Integer.toString(widget), Long.toString(accountId) },
                                        Statuses.CREATED + " desc");
                                if (statuses.moveToFirst()) {
                                    while (!statuses.isAfterLast()) {
                                        if (statuses.getPosition() >= status_count) {
                                            getContentResolver().delete(
                                                    Statuses.getContentUri(MyfeedleService.this),
                                                    Statuses._ID + "=?", new String[] { Long.toString(statuses
                                                            .getLong(statuses.getColumnIndex(Statuses._ID))) });
                                        }
                                        statuses.moveToNext();
                                    }
                                }
                                statuses.close();
                                if (notifications != 0)
                                    publishProgress(Integer.toString(notifications),
                                            friend + " sent a message");
                                widgets.moveToNext();
                            }
                        }
                        widgets.close();
                        return appWidgetIds;
                    }

                    @Override
                    protected void onProgressUpdate(String... updates) {
                        int notifications = Integer.parseInt(updates[0]);
                        if (notifications != 0) {
                            Notification notification = new Notification(R.drawable.notification, updates[1],
                                    System.currentTimeMillis());
                            notification.setLatestEventInfo(getBaseContext(), "New messages", updates[1],
                                    PendingIntent.getActivity(MyfeedleService.this, 0,
                                            (Myfeedle.getPackageIntent(MyfeedleService.this,
                                                    MyfeedleNotifications.class)),
                                            0));
                            notification.defaults |= notifications;
                            ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
                                    .notify(NOTIFY_ID, notification);
                        }
                    }

                    @Override
                    protected void onPostExecute(int[] appWidgetIds) {
                        // remove self from thread list
                        if (!mSMSLoaders.isEmpty())
                            mSMSLoaders.remove(this);
                        putValidatedUpdates(appWidgetIds, 0);
                    }

                };
                mSMSLoaders.add(smsLoader);
                smsLoader.execute(msg);
            }
        } else if (ACTION_PAGE_DOWN.equals(action))
            (new PagingTask()).execute(Integer.parseInt(intent.getData().getLastPathSegment()),
                    intent.getIntExtra(ACTION_PAGE_DOWN, 0));
        else if (ACTION_PAGE_UP.equals(action))
            (new PagingTask()).execute(Integer.parseInt(intent.getData().getLastPathSegment()),
                    intent.getIntExtra(ACTION_PAGE_UP, 0));
        else {
            // this might be a widget update from the widget refresh button
            int appWidgetId;
            try {
                appWidgetId = Integer.parseInt(action);
                putValidatedUpdates(new int[] { appWidgetId }, 1);
            } catch (NumberFormatException e) {
                Log.d(TAG, "unknown action:" + action);
            }
        }
    }
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

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

    setHasOptionsMenu(true);//w ww. j ava 2 s  . c  o m

    /*
     * Load configurations.
     */

    mFileProviderAuthority = getArguments().getString(FileChooserActivity.EXTRA_FILE_PROVIDER_AUTHORITY);
    if (mFileProviderAuthority == null)
        mFileProviderAuthority = LocalFileContract.getAuthority(getActivity());

    mIsMultiSelection = getArguments().getBoolean(FileChooserActivity.EXTRA_MULTI_SELECTION);

    mIsSaveDialog = getArguments().getBoolean(FileChooserActivity.EXTRA_SAVE_DIALOG);
    if (mIsSaveDialog)
        mIsMultiSelection = false;

    mDoubleTapToChooseFiles = getArguments().getBoolean(FileChooserActivity.EXTRA_DOUBLE_TAP_TO_CHOOSE_FILES);

    mRoot = getArguments().getParcelable(FileChooserActivity.EXTRA_ROOTPATH);
    mFilterMode = getArguments().getInt(FileChooserActivity.EXTRA_FILTER_MODE, BaseFile.FILTER_FILES_ONLY);
    mMaxFileCount = getArguments().getInt(FileChooserActivity.EXTRA_MAX_FILE_COUNT, 1000);
    mFileAdapter = new BaseFileAdapter(getActivity(), mFilterMode, mIsMultiSelection);

    /*
     * History.
     */
    if (savedInstanceState != null && savedInstanceState.get(HISTORY) instanceof HistoryStore<?>)
        mHistory = savedInstanceState.getParcelable(HISTORY);
    else
        mHistory = new HistoryStore<Uri>();
    mHistory.addListener(new HistoryListener<Uri>() {

        @Override
        public void onChanged(History<Uri> history) {
            int idx = history.indexOf(getCurrentLocation());
            mViewGoBack.setEnabled(idx > 0);
            mViewGoForward.setEnabled(idx >= 0 && idx < history.size() - 1);
        }// onChanged()
    });
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.event.EventsListingFragment.java

private List<ExplorerObject> getEvents(AbstractLstingFragment.ListingRequest... params) {
    try {//from w  ww  .ja  v a 2  s.  c  om
        Collection<ExplorerObject> result = null;

        Bundle bundle = getArguments();
        boolean my = false;

        if (bundle == null) {
            return Collections.emptyList();
        }
        if (bundle.getBoolean(SearchFragment.ARG_MY))
            my = true;
        String categories = bundle.getString(SearchFragment.ARG_CATEGORY);
        SortedMap<String, Integer> sort = new TreeMap<String, Integer>();
        sort.put("fromTime", 1);
        if (bundle.containsKey(SearchFragment.ARG_CATEGORY)
                && (bundle.getString(SearchFragment.ARG_CATEGORY) != null)) {

            result = Utils.convertToLocalEventFromBean(DTHelper.searchInGeneral(params[0].position,
                    params[0].size, bundle.getString(SearchFragment.ARG_QUERY),
                    (WhereForSearch) bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH),
                    (WhenForSearch) bundle.getParcelable(SearchFragment.ARG_WHEN_SEARCH), my,
                    EventObjectForBean.class, sort, categories));

        } else if (bundle.containsKey(ARG_POI) && (bundle.getString(ARG_POI) != null)) {
            result = Utils.convertToLocalEvent(
                    DTHelper.getEventsByPOI(params[0].position, params[0].size, bundle.getString(ARG_POI)));
        } else if (bundle.containsKey(SearchFragment.ARG_MY) && (bundle.getBoolean(SearchFragment.ARG_MY))) {

            result = Utils.convertToLocalEventFromBean(DTHelper.searchInGeneral(params[0].position,
                    params[0].size, bundle.getString(SearchFragment.ARG_QUERY),
                    (WhereForSearch) bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH),
                    (WhenForSearch) bundle.getParcelable(SearchFragment.ARG_WHEN_SEARCH), my,
                    EventObjectForBean.class, sort, categories));

        } else if (bundle.containsKey(SearchFragment.ARG_QUERY)) {

            result = Utils.convertToLocalEventFromBean(DTHelper.searchInGeneral(params[0].position,
                    params[0].size, bundle.getString(SearchFragment.ARG_QUERY),
                    (WhereForSearch) bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH),
                    (WhenForSearch) bundle.getParcelable(SearchFragment.ARG_WHEN_SEARCH), my,
                    EventObjectForBean.class, sort, categories));

        } else if (bundle.containsKey(ARG_QUERY_TODAY)) {
            result = DTHelper.searchTodayEvents(params[0].position, params[0].size,
                    bundle.getString(SearchFragment.ARG_QUERY));
        } else if (bundle.containsKey(SearchFragment.ARG_LIST)) {
            result = (Collection<ExplorerObject>) bundle.get(SearchFragment.ARG_LIST);
        } else {
            return Collections.emptyList();
        }

        /* conversion to LocalObject */
        listEvents.addAll(result);

        List<ExplorerObject> sorted = new ArrayList<ExplorerObject>(listEvents);
        if (!postProcAndHeader) {
            return sorted;
        } else {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            calToDate(cal);
            long biggerFromTime = cal.getTimeInMillis();
            if (sorted.size() > 0) {
                // listEvents.addAll(postProcForRecurrentEvents(sorted,
                // biggerFromTime));
                return postProcForRecurrentEvents(sorted, biggerFromTime,
                        result.size() == 0 || result.size() < getSize());
            } else {
                return sorted;
            }
        }
    } catch (Exception e) {
        Log.e(EventsListingFragment.class.getName(), "" + e.getMessage());
        e.printStackTrace();
        listEvents = Collections.emptyList();
        return listEvents;
    }
}

From source file:im.neon.activity.VectorRoomActivity.java

@SuppressLint("NewApi")
/**/*from w  w w. j  a  va  2s. co  m*/
 * Send the medias defined in the intent.
 * They are listed, checked and sent when it is possible.
 */
private void sendMediasIntent(final Intent intent) {
    // sanity check
    if ((null == intent) && (null == mLatestTakePictureCameraUri)) {
        return;
    }

    ArrayList<SharedDataItem> sharedDataItems = new ArrayList<>();

    if (null != intent) {
        sharedDataItems = new ArrayList<>(SharedDataItem.listSharedDataItems(intent));
    } else if (null != mLatestTakePictureCameraUri) {
        sharedDataItems.add(new SharedDataItem(Uri.parse(mLatestTakePictureCameraUri)));
        mLatestTakePictureCameraUri = null;
    }

    // check the extras
    if (0 == sharedDataItems.size()) {
        Bundle bundle = intent.getExtras();

        // sanity checks
        if (null != bundle) {
            bundle.setClassLoader(SharedDataItem.class.getClassLoader());

            if (bundle.containsKey(Intent.EXTRA_STREAM)) {
                try {
                    Object streamUri = bundle.get(Intent.EXTRA_STREAM);

                    if (streamUri instanceof Uri) {
                        sharedDataItems.add(new SharedDataItem((Uri) streamUri));
                    } else if (streamUri instanceof List) {
                        List<Object> streams = (List<Object>) streamUri;

                        for (Object object : streams) {
                            if (object instanceof Uri) {
                                sharedDataItems.add(new SharedDataItem((Uri) object));
                            } else if (object instanceof SharedDataItem) {
                                sharedDataItems.add((SharedDataItem) object);
                            }
                        }
                    }
                } catch (Exception e) {
                    Log.e(LOG_TAG, "fail to extract the extra stream");
                }
            } else if (bundle.containsKey(Intent.EXTRA_TEXT)) {
                mEditText.setText(mEditText.getText() + bundle.getString(Intent.EXTRA_TEXT));

                mEditText.post(new Runnable() {
                    @Override
                    public void run() {
                        mEditText.setSelection(mEditText.getText().length());
                    }
                });
            }
        }
    }

    if (0 != sharedDataItems.size()) {
        mVectorRoomMediasSender.sendMedias(sharedDataItems);
    }
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

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

    setHasOptionsMenu(true);/*from w  ww.  j a  va 2  s. co  m*/

    /*
     * Load configurations.
     */

    mFileProviderAuthority = getArguments().getString(FileChooserActivity.EXTRA_FILE_PROVIDER_AUTHORITY);
    if (mFileProviderAuthority == null)
        mFileProviderAuthority = LocalFileContract.getAuthority(getActivity());

    mIsMultiSelection = getArguments().getBoolean(FileChooserActivity.EXTRA_MULTI_SELECTION);

    mIsSaveDialog = FileChooserActivity.ACTION_SAVE.equals(getArguments().getString(EXTRA_ACTION));
    if (mIsSaveDialog)
        mIsMultiSelection = false;

    mDoubleTapToChooseFiles = getArguments().getBoolean(FileChooserActivity.EXTRA_DOUBLE_TAP_TO_CHOOSE_FILES);

    mRoot = getArguments().getParcelable(FileChooserActivity.EXTRA_ROOTPATH);
    mFilterMode = getArguments().getInt(FileChooserActivity.EXTRA_FILTER_MODE, BaseFile.FILTER_FILES_ONLY);
    mMaxFileCount = getArguments().getInt(FileChooserActivity.EXTRA_MAX_FILE_COUNT, 1000);
    mFileAdapter = new BaseFileAdapter(getActivity(), mFilterMode, mIsMultiSelection);
    mFileAdapter.setBuildOptionsMenuListener(mOnBuildOptionsMenuListener);

    /*
     * History.
     */
    if (savedInstanceState != null && savedInstanceState.get(HISTORY) instanceof HistoryStore<?>)
        mHistory = savedInstanceState.getParcelable(HISTORY);
    else
        mHistory = new HistoryStore<Uri>();
    mHistory.addListener(new HistoryListener<Uri>() {

        @Override
        public void onChanged(History<Uri> history) {
            int idx = history.indexOf(getCurrentLocation());
            mViewGoBack.setEnabled(idx > 0);
            mViewGoForward.setEnabled(idx >= 0 && idx < history.size() - 1);
        }// onChanged()
    });
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

@SuppressLint("DefaultLocale")
private void loadExtraDataParms(Intent in) {
    Bundle bundle = in.getExtras();
    if (bundle != null) {
        tabHost.setCurrentTab(1);//from  ww w . j  a  v  a2s.  c  o  m
        String sid = "External Application";
        if (bundle.containsKey(SMBSYNC_SCHEDULER_ID)) {
            if (bundle.get(SMBSYNC_SCHEDULER_ID).getClass().getSimpleName().equals("String")) {
                sid = bundle.getString(SMBSYNC_SCHEDULER_ID);
            }
        }
        util.addLogMsg("I", String.format(mContext.getString(R.string.msgs_extra_data_startup_by), sid));
        if (bundle.containsKey(SMBSYNC_EXTRA_PARM_STARTUP_PARMS)) {
            if (bundle.get(SMBSYNC_EXTRA_PARM_STARTUP_PARMS).getClass().getSimpleName().equals("String")) {
                String op = bundle.getString(SMBSYNC_EXTRA_PARM_STARTUP_PARMS).replaceAll("\"", "")
                        .replaceAll("\'", "");
                //               Log.v("","op="+op);
                boolean[] opa = new boolean[] { false, false, false };
                boolean error = false;
                extraValueSyncProfList = null;
                String[] op_str_array = op.split(",");
                if (op_str_array.length < 3) {
                    error = true;
                    util.addLogMsg("W", String.format(
                            mContext.getString(R.string.msgs_extra_data_startup_parms_length_error), op));
                } else {
                    for (int i = 0; i < 3; i++) {
                        if (op_str_array[i].toLowerCase().equals("false")) {
                            opa[i] = false;
                        } else if (op_str_array[i].toLowerCase().equals("true")) {
                            opa[i] = true;
                        } else {
                            error = true;
                            util.addLogMsg("W",
                                    String.format(
                                            mContext.getString(
                                                    R.string.msgs_extra_data_startup_parms_value_error),
                                            op_str_array[i]));
                            break;
                        }
                    }
                    if (op_str_array.length > 3) {
                        extraValueSyncProfList = new String[op_str_array.length - 3];
                        for (int i = 0; i < op_str_array.length - 3; i++)
                            extraValueSyncProfList[i] = op_str_array[i + 3];
                    }
                }
                if (!error) {
                    isExtraSpecAutoStart = isExtraSpecAutoTerm = isExtraSpecBgExec = true;
                    extraValueAutoStart = opa[0];
                    util.addLogMsg("I", "AutoStart=" + extraValueAutoStart);
                    if (isExtraSpecAutoStart && extraValueAutoStart) {
                        extraValueAutoTerm = opa[1];
                        util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm);
                        extraValueBgExec = opa[2];
                        util.addLogMsg("I", "Background=" + extraValueBgExec);
                    } else {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_auto_start_not_specified),
                                        "AutoTerm"));
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_auto_start_not_specified),
                                        "Background"));
                    }

                    if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_START)) {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_startup_parms_specified),
                                        SMBSYNC_EXTRA_PARM_AUTO_START));
                    }
                    if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_TERM)) {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_startup_parms_specified),
                                        SMBSYNC_EXTRA_PARM_AUTO_TERM));
                    }
                    if (bundle.containsKey(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION)) {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_startup_parms_specified),
                                        SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION));
                    }
                    if (bundle.containsKey(SMBSYNC_EXTRA_PARM_SYNC_PROFILE)) {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_startup_parms_specified),
                                        SMBSYNC_EXTRA_PARM_SYNC_PROFILE));
                    }
                }
            } else {
                util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_startup_parms_type_error));
            }
        } else {
            if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_START)) {
                if (bundle.get(SMBSYNC_EXTRA_PARM_AUTO_START).getClass().getSimpleName().equals("Boolean")) {
                    isExtraSpecAutoStart = true;
                    extraValueAutoStart = bundle.getBoolean(SMBSYNC_EXTRA_PARM_AUTO_START);
                    util.addLogMsg("I", "AutoStart=" + extraValueAutoStart);
                } else {
                    util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_auto_start_not_boolean));
                }
            }
            if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_TERM)) {
                if (bundle.get(SMBSYNC_EXTRA_PARM_AUTO_TERM).getClass().getSimpleName().equals("Boolean")) {
                    if (isExtraSpecAutoStart) {
                        isExtraSpecAutoTerm = true;
                        extraValueAutoTerm = bundle.getBoolean(SMBSYNC_EXTRA_PARM_AUTO_TERM);
                        util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm);
                    } else {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_auto_start_not_specified),
                                        "AutoTerm"));
                    }
                } else {
                    util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_auto_term_not_boolean));
                }
            }
            if (bundle.containsKey(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION)) {
                if (bundle.get(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION).getClass().getSimpleName()
                        .equals("Boolean")) {
                    if (isExtraSpecAutoStart) {
                        isExtraSpecBgExec = true;
                        extraValueBgExec = bundle.getBoolean(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION);
                        util.addLogMsg("I", "Background=" + extraValueBgExec);
                    } else {
                        util.addLogMsg("W",
                                String.format(
                                        mContext.getString(
                                                R.string.msgs_extra_data_ignored_auto_start_not_specified),
                                        "Background"));
                    }

                } else {
                    util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_back_ground_not_boolean));
                }
            }
            if (bundle.containsKey(SMBSYNC_EXTRA_PARM_SYNC_PROFILE)) {
                if (isExtraSpecAutoStart) {
                    if (bundle.get(SMBSYNC_EXTRA_PARM_SYNC_PROFILE).getClass().getSimpleName()
                            .equals("String[]")) {
                        extraValueSyncProfList = bundle.getStringArray(SMBSYNC_EXTRA_PARM_SYNC_PROFILE);
                    } else {
                        util.addLogMsg("W",
                                mContext.getString(R.string.msgs_extra_data_sync_profile_type_error));
                    }
                } else {
                    util.addLogMsg("W",
                            String.format(
                                    mContext.getString(
                                            R.string.msgs_extra_data_ignored_auto_start_not_specified),
                                    "SyncProfile"));
                }
            }
            if (isExtraSpecAutoStart) {
                if (!isExtraSpecAutoTerm) {
                    isExtraSpecAutoTerm = true;
                    extraValueAutoTerm = false;
                    util.addLogMsg("W",
                            mContext.getString(R.string.msgs_extra_data_assumed_auto_term_disabled));
                    util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm);
                }
                if (!isExtraSpecBgExec) {
                    isExtraSpecBgExec = true;
                    extraValueBgExec = false;
                    util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_assumed_bg_exec_disabled));
                    util.addLogMsg("I", "Background=" + extraValueBgExec);
                }
            }
        }
    }
}

From source file:cl.gisred.android.InspActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState.containsKey("Uri")) {
        mImageUri = Uri.parse(savedInstanceState.getString("Uri"));
    }// w  w w  . j  a  va  2s .  c  o m
    if (savedInstanceState.containsKey("req")) {
        int req = (int) savedInstanceState.get("req");
        if (req == ActivityInfo.SCREEN_ORIENTATION_LOCKED)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
    }
}