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:jp.co.conit.sss.sp.ex1.fragment.BookPurchaseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_purchase, container, false);

    Bundle arguments = getArguments();
    mBook = (Book) arguments.get("book");
    String title = mBook.getTitle();
    String outline = mBook.getOutline();

    TextView detailTitle = (TextView) v.findViewById(R.id.detail_title);
    detailTitle.setText(title);//  w ww . j  av  a  2 s.  co m
    TextView detailAuthor = (TextView) v.findViewById(R.id.detail_author);
    detailAuthor.setText(outline);

    mPurchaceBtn = (Button) v.findViewById(R.id.btn_purchace);
    mPurchaceBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (hasBookFile()) {
                mBookPath = FileUtil.generateBookFilePath(getActivity(), mBook);
                intentToBookViewer();
            } else {
                if (isDownloadable()) {
                    downloadBookDataAsync();
                } else {
                    purchaseBook();
                }
            }
        }
    });

    if (hasBookFile()) {
        mPurchaceBtn.setText(getString(R.string.read));
    } else {
        if (isDownloadable()) {
            mPurchaceBtn.setText(getString(R.string.download));
        } else {
            if (mBook.isFree()) {
                mPurchaceBtn.setText(getString(R.string.free));
            } else {
                mPurchaceBtn.setText(getString(R.string.pay));
            }
        }
    }

    return v;
}

From source file:com.teleca.jamendo.activity.SearchActivity.java

@SuppressWarnings("unchecked")
@Override//from   ww w . j  a  va 2  s  .  c  o m
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    mSearchMode = (SearchMode) savedInstanceState.getSerializable("mode");
    if (mSearchMode != null) {
        if (mSearchMode.equals(SearchMode.Artist) || mSearchMode.equals(SearchMode.Tag)
                || mSearchMode.equals(SearchMode.UserStarredAlbums)) {
            AlbumAdapter adapter = new AlbumAdapter(this);
            adapter.setList((ArrayList<Album>) savedInstanceState.get("values"));
            mSearchListView.setAdapter(adapter);
            mSearchListView.setOnItemClickListener(mAlbumClickListener);
        }

        if (mSearchMode.equals(SearchMode.UserPlaylist)) {
            PlaylistRemoteAdapter adapter = new PlaylistRemoteAdapter(this);
            adapter.setList((ArrayList<PlaylistRemote>) savedInstanceState.get("values"));
            mSearchListView.setAdapter(adapter);
            mSearchListView.setOnItemClickListener(mPlaylistClickListener);
        }

        mViewFlipper.setDisplayedChild(savedInstanceState.getInt("flipper_page"));
    }
    super.onRestoreInstanceState(savedInstanceState);
}

From source file:com.downrighttech.dmxdip.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    Log.v("lifeCycle", "onRestoreInstanceState-" + savedInstanceState.toString());
    //if (savedInstanceState != null){
    editText_Span.setText(savedInstanceState.get("span").toString());
    editText_Start.setText(savedInstanceState.get("start").toString());
    super.onRestoreInstanceState(savedInstanceState);
    //}/*from w w  w. j  av  a 2  s  .co m*/
}

From source file:com.itime.team.itime.fragments.MeetingSubPreferenceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mMeetingSubPrefView = inflater.inflate(R.layout.fragment_sub_preference_meeting, null);
    TextView title = (TextView) getActivity().findViewById(R.id.setting_toolbar_title);
    title.setText("Edit Preference");

    Bundle args = getArguments();
    // TODO: new preference does nothing, but indexed preference fetch the values
    if (args != null && args.getBoolean("AddMeetingPreference")) {
        mIsNewPreferences = true;//from w  ww  .j  a va 2  s .  co  m
    }
    if (args != null && !mIsNewPreferences) {
        // TODO: set preferences from last fragment
    }

    bindListener();
    holdViews();
    if (args != null && args.get(PREFERENCE_DATA) != null) {
        mParcelablePreference = args.getParcelable(PREFERENCE_DATA);
    } else {
        newPreference();
    }
    initDataValue();
    initViewsValue();
    return mMeetingSubPrefView;
    //return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.conferenceengineer.android.iosched.ui.SessionsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (getActivity() == null) {
        return;/* ww w  .  j a v  a 2  s. c  om*/
    }

    int token = loader.getId();
    if (token == SessionsQuery._TOKEN || token == SearchQuery._TOKEN) {
        mAdapter.changeCursor(cursor);
        Bundle arguments = getArguments();

        if (arguments != null && arguments.containsKey("_uri")) {
            String uri = arguments.get("_uri").toString();

            if (uri != null && uri.contains("blocks")) {
                String title = arguments.getString(Intent.EXTRA_TITLE);
                if (title == null) {
                    title = (String) this.getActivity().getTitle();
                }
                LOGD("Tracker", "Session Block: " + title);
            }
        }
    } else {
        LOGD(TAG, "Query complete, Not Actionable: " + token);
        cursor.close();
    }

    mMultiSelectionController.tryRestoreInstanceState();
}

From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java

/**
 * Handle authentication activity result bundle.
 *
 * @param bundle Activity result bundle.
 *///w  w  w . j a v a2  s . c o  m
private void handleAuthenticationActivityResultBundle(Bundle bundle) {

    Bundle mvpdBundle = null;
    if (bundle != null) {
        mvpdBundle = (Bundle) bundle.get(AuthenticationConstants.MVPD_BUNDLE);
    }

    if (mvpdBundle == null) {
        Log.w(TAG, "No MVPD bundle found when handling authentication result");
        return;
    }
    String mvpd = mvpdBundle.getString(AuthenticationConstants.MVPD);

    String mvpdLogoUrl = mContentBrowser.getPoweredByLogoUrlByName(mvpd);
    if (mvpdLogoUrl == null || mvpdLogoUrl.isEmpty()) {
        Log.d(TAG, "MVPD url not found for:" + mvpd);
    }
    Preferences.setString(PreferencesConstants.MVPD_LOGO_URL, mvpdLogoUrl);
    Log.d(TAG, "MVPD in details:" + mvpd + " logo url:" + mvpdLogoUrl);

}

From source file:com.dileepindia.cordova.sms.SMSPlugin.java

protected void createIncomingSMSReceiver() {
    Context ctx = this.cordova.getActivity();

    this.mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Log.d("SMSPlugin", "onRecieve: " + action);

            if ("android.provider.Telephony.SMS_RECEIVED".equals(action)) {
                if (SMSPlugin.this.mIntercept) {
                    abortBroadcast();/* www  . j  a v a2  s.co  m*/
                }
                Bundle bundle = intent.getExtras();
                if (bundle != null) {
                    Object[] pdus = (Object[]) bundle.get("pdus");
                    if (pdus.length != 0) {
                        for (int i = 0; i < pdus.length; i++) {
                            SmsMessage sms = SmsMessage.createFromPdu((byte[]) pdus[i]);

                            JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms);
                            SMSPlugin.this.onSMSArrive(json);
                        }

                    }
                }
            }
        }
    };
    String[] filterstr = { "android.provider.Telephony.SMS_RECEIVED" };
    for (int i = 0; i < filterstr.length; i++) {
        IntentFilter filter = new IntentFilter(filterstr[i]);
        filter.setPriority(100);
        ctx.registerReceiver(this.mReceiver, filter);
        Log.d("SMSPlugin", "broadcast receiver registered for: " + filterstr[i]);
    }
}

From source file:com.york.cs.services.SyncAdapter.SyncAdapterCB.java

/**
 * Called by the Android system in response to a request to run the sync
 * adapter. The work required to read data from the network, parse it, and
 * store it done here. Extending AbstractThreadedSyncAdapter ensures that
 * all methods within SyncAdapter run on a background thread. For this
 * reason, blocking I/O and other long-running tasks can be run
 * <em>in situ</em>, and you don't have to set up a separate thread for
 * them. ./*  w  w w.jav a2 s. c o m*/
 * 
 * <p>
 * This is where we actually perform any work required to perform a sync.
 * {@link AbstractThreadedSyncAdapter} guarantees that this will be called
 * on a non-UI thread, so it is safe to peform blocking I/O here.
 * 
 * <p>
 * The syncResult argument allows you to pass information back to the method
 * that triggered the sync.
 */
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {
    Log.d(TAG, "onPerformSync for account");

    // Building a print of the extras we got
    StringBuilder sb = new StringBuilder();
    if (extras != null) {
        for (String key : extras.keySet()) {
            sb.append(key + "[" + extras.get(key) + "] ");
        }
    }

    Log.d(TAG, "onPerformSync for account[" + account.name + "]. Extras: " + sb.toString());

    try {
        // Get the auth token for the current account and
        // the userObjectId, needed for creating items on Parse.com account
        String authToken = mAccountManager.blockingGetAuthToken(account,
                AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, true);
        String userObjectId = mAccountManager.getUserData(account, AccountGeneral.USERDATA_USER_OBJ_ID);

        Log.d(TAG, "start sunc" + authToken + "-" + userObjectId);

        Application application = (Application) getContext();

        Database database = application.getDatabase();
        initObservable();
        startSyncWithCustomCookie(database, authToken);

    } catch (OperationCanceledException e) {
        e.printStackTrace();
    } catch (IOException e) {
        syncResult.stats.numIoExceptions++;
        e.printStackTrace();
    } catch (AuthenticatorException e) {
        syncResult.stats.numAuthExceptions++;
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:li.klass.fhem.fragments.TimerDetailFragment.java

private void setValuesForCurrentTimerDevice(AtDevice atDevice) {
    this.timerDevice = atDevice;

    getActivity()/*  w ww  .j av a2 s . com*/
            .startService(new Intent(GET_DEVICE_FOR_NAME).setClass(getActivity(), RoomListIntentService.class)
                    .putExtra(DEVICE_NAME, atDevice.getTargetDevice())
                    .putExtra(RESULT_RECEIVER, new FhemResultReceiver() {
                        @Override
                        protected void onReceiveResult(int resultCode, Bundle resultData) {
                            if (resultCode == ResultCodes.SUCCESS && resultData.containsKey(DEVICE)) {
                                updateTargetDevice((FhemDevice) resultData.get(DEVICE));
                            }
                        }
                    }));

    this.stateAppendix = timerDevice.getTargetStateAddtionalInformation();
    this.targetState = timerDevice.getTargetState();

    this.repetition = timerDevice.getRepetition();
    this.type = timerDevice.getTimerType();

    this.isActive = timerDevice.isActive();

    this.hour = timerDevice.getHours();
    this.minute = timerDevice.getMinutes();
    this.second = timerDevice.getSeconds();
    this.timerDeviceName = timerDevice.getName();

    updateTimerInformation();
}

From source file:com.arellomobile.android.push.PushManager.java

boolean onHandlePush(Activity activity) {
    Bundle pushBundle = activity.getIntent().getBundleExtra("pushBundle");
    if (null == pushBundle || null == mContext) {
        return false;
    }//w ww .j av a2 s  .co m

    mLastBundle = pushBundle;

    JSONObject dataObject = new JSONObject();
    try {
        if (pushBundle.containsKey("title")) {
            dataObject.put("title", pushBundle.get("title"));
        }
        if (pushBundle.containsKey("u")) {
            dataObject.put("userdata", pushBundle.get("u"));
        }
        if (pushBundle.containsKey("local")) {
            dataObject.put("local", pushBundle.get("local"));
        }
    } catch (JSONException e) {
        // pass
    }

    PushEventsTransmitter.onMessageReceive(mContext, dataObject.toString(), pushBundle);

    // push message handling
    String url = (String) pushBundle.get("h");

    if (url != null) {
        url = String.format(HTML_URL_FORMAT, url);

        // show browser
        Intent intent = new Intent(activity, PushWebview.class);
        intent.putExtra("url", url);
        activity.startActivity(intent);
    }

    // send pushwoosh callback
    sendPushStat(mContext, pushBundle.getString("p"));

    return true;
}