Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:net.gcompris.GComprisActivity.java

public static void buyGCompris() {
    if (m_instance.m_service == null) {
        Log.e(QtApplication.QtTAG, "Buying full version failed: No billing service");
        return;//from   w w w.ja  v  a2 s .  co m
    }

    try {
        Bundle buyIntentBundle = m_instance.m_service.getBuyIntent(3, m_instance.getPackageName(), SKU_NAME,
                "inapp", "");
        int responseCode = buyIntentBundle.getInt("RESPONSE_CODE");
        if (responseCode == 0 /* BILLING_RESPONSE_RESULT_OK */) {
            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
            m_instance.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(),
                    Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
            return;
        } else if (responseCode == 7 /* BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED */) {
            bought(true);
        } else {
            Log.e(QtApplication.QtTAG, "Buying full version failed: Response code == " + responseCode);
        }
    } catch (Exception e) {
        Log.e(QtApplication.QtTAG, "Exception caught when buying full version!", e);
    }
}

From source file:com.neusou.bioroid.restful.RestfulClient.java

public static Parcelable getParcelable(Bundle data, String name) {
    boolean invocation = data.containsKey(name);
    if (!invocation) {
        return null;
    }//w w w. ja  v  a 2s  .c o  m
    return data.getParcelable(name);
}

From source file:Main.java

public static String toString(Intent intent) {
    StringBuilder sb = new StringBuilder();
    sb.append(intent.getAction()).append(" ");

    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        Set<String> sets = bundle.keySet();
        for (String key : sets) {
            if (bundle.get(key) instanceof Integer) {
                sb.append(key).append(":").append(bundle.getInt(key)).append("\n");
            } else if (bundle.get(key) instanceof ArrayList) {
                sb.append(key).append(":").append(Arrays.toString(bundle.getIntegerArrayList(key).toArray()))
                        .append("\n");
            } else if (bundle.get(key) instanceof Parcelable) {
                sb.append(key).append(":").append(bundle.getParcelable(key).toString()).append("\n");
            } else {
                sb.append(key).append(":").append(bundle.getString(key)).append("\n");
            }/*from  www  .  ja v  a  2 s .  c o m*/
        }

    }

    return sb.toString();
}

From source file:androidx.media.SessionToken2.java

/**
 * Create a token from the bundle, exported by {@link #toBundle()}.
 *
 * @param bundle//from   w w w. ja v a2  s  .co m
 * @return
 */
public static SessionToken2 fromBundle(@NonNull Bundle bundle) {
    if (bundle == null) {
        return null;
    }
    final int uid = bundle.getInt(KEY_UID);
    final @TokenType int type = bundle.getInt(KEY_TYPE, -1);
    final String packageName = bundle.getString(KEY_PACKAGE_NAME);
    final String serviceName = bundle.getString(KEY_SERVICE_NAME);
    final String id = bundle.getString(KEY_ID);
    final MediaSessionCompat.Token token = bundle.getParcelable(KEY_SESSION_TOKEN);

    // Sanity check.
    switch (type) {
    case TYPE_SESSION:
        if (token == null) {
            throw new IllegalArgumentException(
                    "Unexpected token for session," + " SessionCompat.Token=" + token);
        }
        break;
    case TYPE_SESSION_SERVICE:
    case TYPE_LIBRARY_SERVICE:
        if (TextUtils.isEmpty(serviceName)) {
            throw new IllegalArgumentException("Session service needs service name");
        }
        break;
    default:
        throw new IllegalArgumentException("Invalid type");
    }
    if (TextUtils.isEmpty(packageName) || id == null) {
        throw new IllegalArgumentException("Package name nor ID cannot be null.");
    }
    return new SessionToken2(uid, type, packageName, serviceName, id, token);
}

From source file:com.ademsha.appnotifico.NotificationDataHelper.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static JSONObject getNotificationExtras(JSONObject notification,
        StatusBarNotification statusBarNotification) {
    try {/*from   w  ww  . j a v a2s.  c om*/
        Bundle extras = statusBarNotification.getNotification().extras;
        if (extras != null) {
            notification.put("text", extras.getString(Notification.EXTRA_TEXT));
            notification.put("sub_text", extras.getString(Notification.EXTRA_SUB_TEXT));
            notification.put("summary_text", extras.getString(Notification.EXTRA_SUMMARY_TEXT));
            notification.put("text_lines", Arrays
                    .toString(extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)).replace("null", ""));
            notification.put("icon", String.valueOf(extras.getInt(Notification.EXTRA_SMALL_ICON)));
            if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) {
                notification.put("large_icon",
                        String.valueOf(extras.getParcelable(Notification.EXTRA_LARGE_ICON).toString())
                                .replace("null", ""));
            }
            notification.put("title", extras.getString(Notification.EXTRA_TITLE));
            notification.put("title_big", extras.getString(Notification.EXTRA_TITLE_BIG));
            notification.put("progress", extras.getInt(Notification.EXTRA_PROGRESS));
            notification.put("progress_indeterminate",
                    String.valueOf(extras.getBoolean(Notification.EXTRA_PROGRESS_INDETERMINATE)));
            notification.put("progress_max", String.valueOf(extras.getInt(Notification.EXTRA_PROGRESS_MAX)));
            notification.put("people", extras.getStringArray(Notification.EXTRA_PEOPLE));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return notification;
}

From source file:com.binary_machinery.avalonschedule.view.schedule.EmptyRecordFragment.java

@Nullable
@Override/*from  ww  w . j av a  2 s .  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.empty_record_list_element, container, false);

    Bundle arguments = getArguments();
    ScheduleRecord record = arguments.getParcelable(ARG_RECORD);
    if (record != null) {
        setText(view, R.id.record_date, Constants.DATE_FORMAT.format(record.date));
        setText(view, R.id.record_weekday, record.weekday);

        int color = Utils.getColorForRecord(view, record);
        view.findViewById(R.id.record_root_layout).setBackgroundColor(color);
    }

    return view;
}

From source file:com.binary_machinery.avalonschedule.view.schedule.RecordFragment.java

@Nullable
@Override//from  w  w w.  j  av a2s  . c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.records_list_element, container, false);

    Bundle arguments = getArguments();
    ScheduleRecord record = arguments.getParcelable(ARG_RECORD);
    if (record != null) {
        setText(view, R.id.record_date, Constants.DATE_FORMAT.format(record.date));
        setText(view, R.id.record_weekday, record.weekday);
        setText(view, R.id.record_time, record.time);
        setText(view, R.id.record_type, record.type);
        setText(view, R.id.record_room, record.room);
        setText(view, R.id.record_course, record.course);
        setText(view, R.id.record_lecturer, record.lecturer);

        int color = Utils.getColorForRecord(view, record);
        view.findViewById(R.id.record_root_layout).setBackgroundColor(color);
    }

    return view;
}

From source file:android.support.car.ui.CarActionExtender.java

public CarActionExtender(NotificationCompat.Action action) {
    Bundle autoBundle = action.getExtras();

    if (autoBundle != null) {
        mIntent = autoBundle.getParcelable(EXTRA_INTENT);
    }// w w w.j a va2s.com
}

From source file:com.savvywits.wethepeople.RESTService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    ResultReceiver receiver = extras.getParcelable("receiver");
    String data = extras.getString("zipcode");
    String url = ZIP_CODE_BASE + data;

    Bundle bundle = new Bundle();
    receiver.send(STATUS_RUNNING, Bundle.EMPTY);
    try {//www .  jav  a  2  s. co  m
        String json = EntityUtils.toString(new DefaultHttpClient().execute(new HttpGet(url)).getEntity());

        if (!validateJSON(json)) {
            receiver.send(STATUS_ERROR, Bundle.EMPTY);
        } else {
            bundle.putString("rest_result", json);
            receiver.send(STATUS_FINISHED, bundle);
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        bundle.putString(Intent.EXTRA_TEXT, e.toString());
        receiver.send(STATUS_ERROR, bundle);
    }
}

From source file:ca.frozen.curlingtv.activities.VideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // configure the activity
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    Log.d(TAG, "onCreate");

    // load the settings and cameras
    Utils.loadData();/*from  ww  w . jav a2s .c  o m*/

    // get the camera object
    Bundle data = getIntent().getExtras();
    camera = data.getParcelable(CAMERA);

    // get the frame layout, handle system visibility changes
    frameLayout = (FrameLayout) findViewById(R.id.video);
    frameLayout.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                videoFragment.startFadeIn();
            }
        }
    });

    // set full screen layout
    int visibility = frameLayout.getSystemUiVisibility();
    visibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
    frameLayout.setSystemUiVisibility(visibility);

    // create the video fragment
    videoFragment = videoFragment.newInstance(camera, true);
    FragmentTransaction fragTran = getSupportFragmentManager().beginTransaction();
    fragTran.add(R.id.video, videoFragment);
    fragTran.commit();
}