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:eu.trentorise.smartcampus.jp.ItineraryChoicesFragment.java

@SuppressWarnings("unchecked")
@Override/*from  w  w w  .  jav a2s  .c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(JOURNEY)) {
            singleJourney = (SingleJourney) savedInstanceState.get(JOURNEY);
        }
        if (savedInstanceState.containsKey(ITINERARIES)) {
            itineraries = (List<Itinerary>) savedInstanceState.get(ITINERARIES);
        }
        if (savedInstanceState.containsKey(LOADED)) {
            mLoaded = savedInstanceState.getBoolean(LOADED);
        }
    }
}

From source file:com.mobileobservinglog.support.billing.DonationBillingHandler.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        Log.d("JoeDebug", "Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {//from w  w w.  ja  v  a2 s.  co m
        Log.e("DonationBillingHandler", "Unexpected type for bundle response code.");
        Log.e("DonationBillingHandler", o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.mpgtracker.tallmatt.mpgtracker.ui.CarEditActivity.java

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

    if (!getIntent().hasExtra(KEY_CURRENT_ACTIVE_CAR)) {
        finish();//from  ww  w .j a  v a 2s  .c  o  m
    }

    setContentView(R.layout.activity_car_edit);
    ButterKnife.bind(this);
    dataPointDatabaseHelper = new DataPointDatabaseHelper(this);

    currentActiveCar = (Car) getIntent().getSerializableExtra(KEY_CURRENT_ACTIVE_CAR);
    carDuplicate = Car.duplicate(currentActiveCar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("Edit Car");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    header = (LinearLayout) layoutInflater.inflate(R.layout.adapter_edit_header, null, false);
    dataPointsList.addHeaderView(header);
    footer = (LinearLayout) layoutInflater.inflate(R.layout.adapter_edit_footer, null, false);
    dataPointsList.addFooterView(footer);

    makeEdit = (EditText) header.findViewById(R.id.edit_car_make);
    makeEdit.setText(currentActiveCar.getMake());
    modelEdit = (EditText) header.findViewById(R.id.edit_car_model);
    modelEdit.setText(currentActiveCar.getModel());
    yearEdit = (EditText) header.findViewById(R.id.edit_car_year);
    yearEdit.setText(currentActiveCar.getYear());
    licenseEdit = (EditText) header.findViewById(R.id.edit_car_license);
    licenseEdit.setText(currentActiveCar.getLicense());
    nameEdit = (EditText) header.findViewById(R.id.edit_car_name);
    nameEdit.setText(currentActiveCar.getName());

    requiredText = (TextView) header.findViewById(R.id.edit_car_required);

    deleteButton = (Button) footer.findViewById(R.id.edit_delete);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            areYouSure("Delete car? This can't be undone.", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    setResult(RESULT_DELETE);
                    finish();
                }
            });
        }
    });

    editDataPointAdapter = new EditDataPointAdapter(this, currentActiveCar.getDataPoints());
    dataPointsList.setAdapter(editDataPointAdapter);
    dataPointsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final int fixedPosition = position - 1;
            FragmentManager fm = getSupportFragmentManager();
            NewDataPointDialogFragment newDataPointDialogFragment = NewDataPointDialogFragment
                    .newInstance(currentActiveCar.getDataPoints().get(fixedPosition), new DialogListener() {
                        @Override
                        public void onDialogClose(Bundle args) {

                            if (args != null) {

                                DataPoint updatedDataPoint = (DataPoint) args
                                        .get(NewDataPointDialogFragment.KEY_NEW_DATA_POINT);

                                updatedPoints.add(updatedDataPoint);
                                currentActiveCar.updateDataPoint(updatedDataPoint);

                                editDataPointAdapter.notifyDataSetChanged();
                            } else {

                                DataPoint removedDataPoint = currentActiveCar.getDataPoints()
                                        .get(fixedPosition);
                                // if the point is in the updated list then remove it
                                updatedPoints.remove(removedDataPoint);
                                deletedPoints.add(removedDataPoint);
                                currentActiveCar.deleteDataPoint(removedDataPoint);

                                editDataPointAdapter.notifyDataSetChanged();
                            }
                        }
                    });
            newDataPointDialogFragment.show(fm, "dialog_new_data_point");
        }
    });
}

From source file:cn.edu.nuc.seeworld.fg.ColorFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == CAMERA && resultCode == Activity.RESULT_OK && null != data) {
        String sdState = Environment.getExternalStorageState();
        if (!sdState.equals(Environment.MEDIA_MOUNTED)) {
            return;
        }//from   ww  w  .j  a  v  a2 s .  co m
        String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
        Bundle bundle = data.getExtras();
        //????
        Bitmap bitmap = (Bitmap) bundle.get("data");
        FileOutputStream fout = null;
        File file = new File("/sdcard/pintu/");
        file.mkdirs();
        String filename = file.getPath() + name;
        try {
            fout = new FileOutputStream(filename);
            pic_path = filename;
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            try {
                fout.flush();
                fout.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        pic_imageView.setImageBitmap(bitmap);
        pic_imageView.setVisibility(View.VISIBLE);
    }
    if (requestCode == PHOTO && resultCode == Activity.RESULT_OK && null != data) {

        Uri selectedImage = data.getData();
        String[] filePathColumns = { MediaStore.Images.Media.DATA };
        Cursor c = this.getActivity().getContentResolver().query(selectedImage, filePathColumns, null, null,
                null);
        c.moveToFirst();
        int columnIndex = c.getColumnIndex(filePathColumns[0]);
        String picturePath = c.getString(columnIndex);
        c.close();
        //?
        Log.d("SEEWORLDTAG", picturePath);
        Bitmap bitmap = BitmapFactory.decodeFile(picturePath);
        pic_path = picturePath;
        pic_imageView.setImageBitmap(bitmap);
        pic_imageView.setVisibility(View.VISIBLE);
    }
}

From source file:com.chilliworks.chillisource.core.LocalNotificationReceiver.java

/**
 * Called when a local notification broad cast is received. Funnels the notification
 * into the app if open or into the notification bar if not
 * //from w  ww  . j a va  2 s.co  m
 * @author Steven Hendrie
 * 
 * @param The context.
 * @param The intent.
 */
@SuppressWarnings("deprecation")
@Override
public void onReceive(Context in_context, Intent in_intent) {
    //evaluate whether or not the main engine activity is in the foreground
    boolean isAppInForeground = false;
    if (CSApplication.get() != null && CSApplication.get().isActive() == true) {
        isAppInForeground = true;
    }

    //if the main engine activity is in the foreground, simply pass the
    //notification into it. Otherwise display a notification.
    if (isAppInForeground == true) {
        final Intent intent = new Intent(in_intent.getAction());
        Bundle mapParams = in_intent.getExtras();
        Iterator<String> iter = mapParams.keySet().iterator();

        while (iter.hasNext()) {
            String strKey = iter.next();
            intent.putExtra(strKey, mapParams.get(strKey).toString());
        }

        LocalNotificationNativeInterface localNotificationNI = (LocalNotificationNativeInterface) CSApplication
                .get().getSystem(LocalNotificationNativeInterface.InterfaceID);
        if (localNotificationNI != null) {
            localNotificationNI.onNotificationReceived(intent);
        }
    } else {
        //aquire a wake lock
        if (s_wakeLock != null) {
            s_wakeLock.release();
        }

        PowerManager pm = (PowerManager) in_context.getSystemService(Context.POWER_SERVICE);
        s_wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
                | PowerManager.ON_AFTER_RELEASE, "NotificationWakeLock");
        s_wakeLock.acquire();

        //pull out the information from the intent
        Bundle params = in_intent.getExtras();
        CharSequence title = params.getString(k_paramNameTitle);
        CharSequence text = params.getString(k_paramNameBody);
        int intentId = params.getInt(LocalNotification.k_paramNameNotificationId);

        int paramSize = params.size();
        String[] keys = new String[paramSize];
        String[] values = new String[paramSize];
        Iterator<String> iter = params.keySet().iterator();
        int paramNumber = 0;
        while (iter.hasNext()) {
            keys[paramNumber] = iter.next();
            values[paramNumber] = params.get(keys[paramNumber]).toString();
            ++paramNumber;
        }

        Intent openAppIntent = new Intent(in_context, CSActivity.class);
        openAppIntent.setAction("android.intent.action.MAIN");
        openAppIntent.addCategory("android.intent.category.LAUNCHER");
        openAppIntent.putExtra(k_appOpenedFromNotification, true);
        openAppIntent.putExtra(k_arrayOfKeysName, keys);
        openAppIntent.putExtra(k_arrayOfValuesName, values);
        openAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent sContentIntent = PendingIntent.getActivity(in_context, intentId, openAppIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        Bitmap largeIconBitmap = null;
        int LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context,
                ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify_large");

        //Use small icon if no large icon
        if (LargeIconID == 0) {
            LargeIconID = ResourceHelper.GetDynamicResourceIDForField(in_context,
                    ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify");
        }

        if (LargeIconID > 0) {
            largeIconBitmap = BitmapFactory.decodeResource(in_context.getResources(), LargeIconID);
        }

        Notification notification = new NotificationCompat.Builder(in_context).setContentTitle(title)
                .setContentText(text)
                .setSmallIcon(ResourceHelper.GetDynamicResourceIDForField(in_context,
                        ResourceHelper.RESOURCE_SUBCLASS.RESOURCE_DRAWABLE, "ic_stat_notify"))
                .setLargeIcon(largeIconBitmap).setContentIntent(sContentIntent).build();

        NotificationManager notificationManager = (NotificationManager) in_context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(intentId, notification);
        Toast.makeText(in_context, text, Toast.LENGTH_LONG).show();
    }
}

From source file:fm.smart.r1.activity.CreateExampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ExceptionHandler.register(this);
    setContentView(R.layout.create_example);
    final Intent queryIntent = getIntent();
    Bundle extras = queryIntent.getExtras();
    item_id = (String) extras.get("item_id");
    list_id = (String) extras.get("list_id");
    if (list_id == null || list_id.equals("")) {
        list_id = Main.default_study_list_id;
    }/*  w w  w . j  a  v  a 2  s.  c  o  m*/

    cue = (String) extras.get("cue");
    example = (String) extras.get("example");
    translation = (String) extras.get("translation");
    example_language = (String) extras.get("example_language");
    translation_language = (String) extras.get("translation_language");
    example_transliteration = (String) extras.get("example_transliteration");
    translation_transliteration = (String) extras.get("translation_transliteration");

    TextView example_text = (TextView) findViewById(R.id.create_example_sentence);
    if (!TextUtils.isEmpty(example)) {
        example_text.setText(example);
    }
    example_text.setHint(example_language + " sentence with " + cue);
    TextView translation_text = (TextView) findViewById(R.id.create_example_translation);
    if (!TextUtils.isEmpty(translation)) {
        translation_text.setText(translation);
    }
    translation_text.setHint(translation_language + " translation of example sentence");

    Button button = (Button) findViewById(R.id.create_example_submit);
    button.setOnClickListener(this);

    TextView translation_text_legend = (TextView) findViewById(R.id.create_example_translation_legend);

    TextView sentence_transliteration_textView = (TextView) findViewById(
            R.id.create_example_sentence_transliteration);
    EditText sentence_transliteration_input_textView = (EditText) findViewById(R.id.sentence_transliteration);
    if (!Utils.isIdeographicLanguage(Main.search_lang)) {
        sentence_transliteration_textView.setVisibility(View.GONE);
        sentence_transliteration_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(example_transliteration)) {
        sentence_transliteration_input_textView.setText(example_transliteration);
    }

    TextView translation_transliteration_textView = (TextView) findViewById(
            R.id.create_example_translation_transliteration);
    EditText translation_transliteration_input_textView = (EditText) findViewById(
            R.id.translation_transliteration);
    if (!Utils.isIdeographicLanguage(Main.result_lang)) {
        translation_transliteration_textView.setVisibility(View.GONE);
        translation_transliteration_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(translation_transliteration)) {
        translation_transliteration_input_textView.setText(translation_transliteration);
    }

}

From source file:io.v.android.apps.syncslides.FullscreenSlideFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle args = savedInstanceState;
    if (args == null) {
        args = getArguments();/* w  ww .  j av  a 2  s .  co m*/
    }
    mDeckId = args.getString(DECK_ID_KEY);
    mPresentationId = args.getString(PRESENTATION_ID_KEY);
    mSlideNum = args.getInt(SLIDE_NUM_KEY);
    mLoadingSlideNum = -1;
    mRole = (Role) args.get(ROLE_KEY);

    DB db = DB.Singleton.get(getActivity().getApplicationContext());
    db.getSlides(mDeckId, new DB.Callback<List<Slide>>() {
        @Override
        public void done(List<Slide> slides) {
            mSlides = slides;
            // The CurrentSlideListener could have been notified while we were waiting for
            // the slides to load.
            if (mLoadingSlideNum != -1) {
                currentSlideChanged(mLoadingSlideNum);
            } else {
                currentSlideChanged(mSlideNum);
            }
        }
    });

    // See comment at the top of fragment_slide_list.xml.
    ((PresentationActivity) getActivity()).setUiImmersive(true);
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_fullscreen_slide, container, false);
    mFullScreenImage = (ImageView) rootView.findViewById(R.id.fullscreen_slide_image);
    mFullScreenImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((PresentationActivity) getActivity()).showNavigateFragment(mSlideNum);
        }
    });
    return rootView;
}

From source file:com.listomate.activities.AccountsActivity.java

/**
 * Registers for C2DM messaging with the given account name.
 * /*from ww w .j ava  2s .co m*/
 * @param accountName a String containing a Google account name
 */
private void register(final String accountName) {
    // Store the account name in shared preferences
    final SharedPreferences prefs = Util.getSharedPreferences(mContext);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(Util.ACCOUNT_NAME, accountName);
    editor.putString(Util.AUTH_COOKIE, null);
    editor.commit();

    // Obtain an auth token and register
    AccountManager mgr = AccountManager.get(mContext);
    Account[] accts = mgr.getAccountsByType("com.google");
    for (Account acct : accts) {
        if (acct.name.equals(accountName)) {
            if (Util.isDebug(mContext)) {
                // Use a fake cookie for the dev mode app engine server
                // The cookie has the form email:isAdmin:userId
                // We set the userId to be the same as the account name
                String authCookie = "dev_appserver_login=" + accountName + ":false:" + accountName;
                prefs.edit().putString(Util.AUTH_COOKIE, authCookie).commit();
                C2DMessaging.register(mContext, Setup.SENDER_ID);
            } else {
                // Get the auth token from the AccountManager and convert
                // it into a cookie for the appengine server
                mgr.getAuthToken(acct, "ah", null, this, new AccountManagerCallback<Bundle>() {
                    public void run(AccountManagerFuture<Bundle> future) {
                        try {
                            Bundle authTokenBundle = future.getResult();
                            String authToken = authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString();
                            String authCookie = getAuthCookie(authToken);
                            prefs.edit().putString(Util.AUTH_COOKIE, authCookie).commit();

                            C2DMessaging.register(mContext, Setup.SENDER_ID);
                        } catch (AuthenticatorException e) {
                            Log.w(TAG, "Got AuthenticatorException " + e);
                            Log.w(TAG, Log.getStackTraceString(e));
                        } catch (IOException e) {
                            Log.w(TAG, "Got IOException " + Log.getStackTraceString(e));
                            Log.w(TAG, Log.getStackTraceString(e));
                        } catch (OperationCanceledException e) {
                            Log.w(TAG, "Got OperationCanceledException " + e);
                            Log.w(TAG, Log.getStackTraceString(e));
                        }
                    }
                }, null);
            }
            break;
        }
    }
}

From source file:fm.smart.r1.activity.CreateItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ExceptionHandler.register(this);
    setContentView(R.layout.create_item);
    final Intent queryIntent = getIntent();
    Bundle extras = queryIntent.getExtras();
    list_id = (String) extras.get("list_id");
    cue = (String) extras.get("cue");
    response = (String) extras.get("response");
    cue_language = (String) extras.get("cue_language");
    response_language = (String) extras.get("response_language");
    character_cue = (String) extras.get("character_cue");
    character_response = (String) extras.get("character_response");
    pos = (String) extras.get("pos");

    Button button = (Button) findViewById(R.id.create_item_submit);
    button.setOnClickListener(this);

    TextView cue_text = (TextView) findViewById(R.id.cue);
    if (!TextUtils.isEmpty(cue)) {
        cue_text.setText(cue);// w w w.  j  av  a 2 s  .  c  o m
    }
    TextView response_text = (TextView) findViewById(R.id.response);
    if (!TextUtils.isEmpty(response)) {
        response_text.setText(response);
    }
    TextView cue_character_text = (TextView) findViewById(R.id.cue_character);
    if (!TextUtils.isEmpty(character_cue)) {
        cue_character_text.setText(character_cue);
    }
    TextView response_character_text = (TextView) findViewById(R.id.response_character);
    if (!TextUtils.isEmpty(character_response)) {
        response_character_text.setText(character_response);
    }

    TextView cue_legend = (TextView) findViewById(R.id.create_item_cue_legend);
    cue_legend.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Term");
    TextView response_legend = (TextView) findViewById(R.id.create_item_response_legend);
    response_legend.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Term");
    TextView cue_character_textView = (TextView) findViewById(R.id.create_item_cue_character);
    cue_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Character Text");
    TextView response_character_textView = (TextView) findViewById(R.id.create_item_response_character);
    response_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Character Text");

    List<String> pos_list = new Vector<String>(Utils.POS_MAP.keySet());
    Collections.sort(pos_list);

    ArrayAdapter<String> pos_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            pos_list);
    // .simple_spinner_item
    Spinner pos_textView = (Spinner) findViewById(R.id.pos);
    pos_textView.setAdapter(pos_adapter);
    if (!TextUtils.isEmpty(pos)) {
        pos_textView.setSelection(pos_list.indexOf(pos));
    } else {
        pos_textView.setSelection(pos_list.indexOf("Noun"));
    }

    EditText cue_character_input_textView = (EditText) findViewById(R.id.cue_character);
    if (!Utils.isIdeographicLanguage(Main.search_lang)) {
        cue_character_textView.setVisibility(View.GONE);
        cue_character_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(character_cue)) {
        cue_character_input_textView.setText(character_cue);
    }

    EditText response_character_input_textView = (EditText) findViewById(R.id.response_character);
    if (!Utils.isIdeographicLanguage(Main.result_lang)) {
        response_character_textView.setVisibility(View.GONE);
        response_character_input_textView.setVisibility(View.GONE);
    } else if (!TextUtils.isEmpty(character_response)) {
        response_character_input_textView.setText(character_response);
    }

}

From source file:com.geoffreybuttercrumbs.arewethereyet.ZonePicker.java

public void setNewAlarmZone(Bundle extras) {
    zone.setRadius(extras.getInt(RADIUS));
    zone.setCenter((Location) extras.get(LOC));
    animateTo(zone.getLocation());/*from  www . j a  v  a 2s  .c o m*/
    everTouched = true;
}