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:fr.pronoschallenge.afreechart.AFreeChartAnnotationActivity.java

/**
 * Called when the activity is starting.
 * @param savedInstanceState/*from  w  ww  . ja  v a2s.  co  m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle objetbunble = this.getIntent().getExtras();
    setItemName((String) objetbunble.get("item"));
    setMode((Integer) objetbunble.get("mode"));

    new EvolutionTask(this).execute(getItemName());
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTitle(getString(R.string.title_evolution));

}

From source file:de.sopamo.triangula.android.GameActivity.java

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

    Bundle b = getIntent().getExtras();
    if (b != null) {
        level = (Level) b.get("level");
    } else {//from  w  w w  .  j  a  v  a2  s  .c o m
        level = new Level1();
    }

    mGameGlSurfaceView = new GameGLSurfaceView(this);

    setContentView(R.layout.main);
    LinearLayout ll = (LinearLayout) findViewById(R.id.layout_main);
    ll.addView(mGameGlSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    status = (TextView) findViewById(R.id.tv_status);
    // Disable hiding for debug
    if (true) {
        status.setVisibility(View.GONE);
    }

    SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE);
    sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_NORMAL);

    mGameGlSurfaceView.init();

}

From source file:com.commonsware.cwac.locpoll.demo.LocationReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    mContext = context;//  w w  w.ja  va 2s. c om

    File log = new File(Environment.getExternalStorageDirectory(), "LocationLog.txt");

    try {
        BufferedWriter out = new BufferedWriter(new FileWriter(log.getAbsolutePath(), log.exists()));

        out.write(new Date().toString());
        out.write(" : ");

        Bundle b = intent.getExtras();
        loc = (Location) b.get(LocationPoller.EXTRA_LOCATION);
        String msg;

        if (loc == null) {
            loc = (Location) b.get(LocationPoller.EXTRA_LASTKNOWN);

            if (loc == null) {
                msg = intent.getStringExtra(LocationPoller.EXTRA_ERROR);
            } else {
                msg = "TIMEOUT, lastKnown=" + loc.toString();
            }
        } else {
            msg = loc.toString();
            Log.d("Location Poller", msg);

            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

            if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSDPA)) {
                Log.d("Type", "3g");// for 3g HSDPA networktype will be return as
                // per testing(real) in device with 3g enable data
                // and speed will also matters to decide 3g network type
                type = 2;
            } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_HSPAP)) {
                Log.d("Type", "4g"); // /No specification for the 4g but from wiki
                // i found(HSPAP used in 4g)
                // http://goo.gl/bhtVT
                type = 3;
            } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_GPRS)) {
                Log.d("Type", "GPRS");
                type = 1;
            } else if ((tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE)) {
                Log.d("Type", "EDGE 2g");
                type = 0;
            }

            /* Update the listener, and start it */
            MyListener = new MyPhoneStateListener();
            Tel = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
            Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
        }

        if (msg == null) {
            msg = "Invalid broadcast received!";
        }

        out.write(msg);
        out.write("\n");
        out.close();
    } catch (IOException e) {
        Log.e(getClass().getName(), "Exception appending to log file", e);
    }
}

From source file:com.brodev.socialapp.view.BlogDetail.java

/** Called when the activity is first created. */
@Override/*from w w w  . j  a  v a 2 s .  c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blog_content_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    blog = (Blog) bundle.get("blog");

    user = (User) getApplicationContext();
    colorView = new ColorView(getApplicationContext());
    this.imageGetter = new ImageGetter(getApplicationContext());

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    if (blog.getTime_stamp().equals("0")) {
        this.getBlogAdapter();
    }

    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "blog");
    comment.putInt("itemId", blog.getBlog_id());
    comment.putInt("totalComment", blog.getTotal_comment());
    comment.putInt("total_like", blog.getTotal_like());
    comment.putBoolean("no_share", blog.getShare());
    comment.putBoolean("is_liked", blog.getIs_like());
    comment.putBoolean("can_post_comment", blog.isCanPostComment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();
}

From source file:io.teak.sdk.GooglePlay.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return (Integer) o;
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {// w w  w . j  av a  2  s.  c  om
        Log.e(LOG_TAG, "Unexpected type for bundle response code.");
        Log.e(LOG_TAG, o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.brodev.socialapp.view.VideoPlay.java

/** Called when the activity is first created. */
@Override/* w  ww.j av a 2 s. co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_player);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    user = (User) getApplication().getApplicationContext();
    phraseManager = new PhraseManager(getApplicationContext());
    colorView = new ColorView(getApplicationContext());

    Bundle bundle = getIntent().getExtras();

    video = (Video) bundle.get("video");
    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "video.video"));
    if (video.getTime_stamp().equals("0")) {
        this.getVideoAdapter();
    }

    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "video");
    comment.putInt("itemId", video.getVideo_id());
    comment.putInt("totalComment", video.getTotal_comment());
    comment.putInt("total_like", video.getTotal_like());
    comment.putBoolean("is_liked", video.getIs_like());
    comment.putBoolean("can_post_comment", video.getCan_post_comment());
    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();

}

From source file:beauty.beautydemo.screens.ImagePagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_image_pager);

    Bundle bundle = getIntent().getExtras();
    assert bundle != null;
    ArrayList<MyIcon> imageUrls = (ArrayList<MyIcon>) bundle.get("list");
    int pagerPosition = bundle.getInt("position", 0);

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }//from  www  . ja  va2  s . co  m

    options = Options.getListOptions();

    pager = (ViewPager) findViewById(R.id.pager);

    imagePagerAdapter = new ImagePagerAdapter(imageUrls);
    pager.setAdapter(imagePagerAdapter);
    pager.setCurrentItem(pagerPosition);

}

From source file:com.google.android.apps.chrometophone.C2DMReceiver.java

@Override
public void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String url = (String) extras.get("url");
        String title = (String) extras.get("title");
        String sel = (String) extras.get("sel");
        String debug = (String) extras.get("debug");

        if (debug != null) {
            // server-controlled debug - the server wants to know
            // we received the message, and when. This is not user-controllable,
            // we don't want extra traffic on the server or phone. Server may
            // turn this on for a small percentage of requests or for users
            // who report issues.
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet get = new HttpGet(DeviceRegistrar.BASE_URL + "/debug?id=" + extras.get("collapse_key"));
            // No auth - the purpose is only to generate a log/confirm delivery
            // (to avoid overhead of getting the token)
            try {
                client.execute(get);//from w w w.  j  a  v a  2 s. c  o  m
            } catch (ClientProtocolException e) {
                // ignore
            } catch (IOException e) {
                // ignore
            }
        }

        if (title != null && url != null && url.startsWith("http")) {
            SharedPreferences settings = Prefs.get(context);
            Intent launchIntent = getLaunchIntent(context, url, title, sel);

            if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
                playNotificationSound(context);
                context.startActivity(launchIntent);
            } else {
                if (sel != null && sel.length() > 0) { // have selection
                    generateNotification(context, sel, context.getString(R.string.copied_desktop_clipboard),
                            launchIntent);
                } else {
                    generateNotification(context, url, title, launchIntent);
                }
            }
        }
    }
}

From source file:disono.webmons.com.clean_architecture.presentation.ui.fragments.settings.GeneralSettingsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");

        if (imageBitmap != null) {
            // CALL THIS METHOD TO GET THE ACTUAL PATH
            uriImage = WBFile.bmpToFile(mActivity, imageBitmap);
        }/*ww  w.  j a v a  2s . co m*/
    }
}

From source file:com.secbro.qark.exportedcomponent.exportedactivity.IntentParamsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_CODE: {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                Map resultMap = new HashMap<Object, Object>();
                Bundle bundle = data.getExtras();
                for (String key : bundle.keySet()) {
                    Object value = bundle.get(key);
                    Log.d("key", key);
                    Log.d("value", value.toString());
                    resultMap.put(key, value);
                }//from   w ww. j a v a 2 s  .  c  om
                //Call container activity back to display result
                if (mListener != null) {
                    mListener.onActivityResultListener(resultMap);
                } else {
                    Log.e(LOG_TAG, "mListener is null");
                }
            }
        } else {
            Log.d("INFO", "No data received");
        }
    }
    }
}