Example usage for android.os Bundle putByteArray

List of usage examples for android.os Bundle putByteArray

Introduction

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

Prototype

@Override
public void putByteArray(@Nullable String key, @Nullable byte[] value) 

Source Link

Document

Inserts a byte array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

private AlertDialog.Builder xshowIntroductionInvite(final Activity act, final Bundle args) {
    String exchName = args.getString(extra.EXCH_NAME);
    final String introName = args.getString(extra.INTRO_NAME);
    final byte[] introPhoto = args.getByteArray(extra.PHOTO);
    final byte[] introPush = args.getByteArray(extra.PUSH_REGISTRATION_ID);
    final byte[] introPubKey = args.getByteArray(extra.INTRO_PUBKEY);
    final long msgRowId = args.getLong(extra.MESSAGE_ROW_ID);
    AlertDialog.Builder ad = new AlertDialog.Builder(act);
    View layout;/*from  w  w  w .  ja  v a2 s.  c o  m*/
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        layout = View.inflate(new ContextThemeWrapper(act, R.style.Theme_AppCompat), R.layout.secureinvite,
                null);
    } else {
        LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        layout = inflater.inflate(R.layout.secureinvite, null);
    }
    TextView textViewExchName = (TextView) layout.findViewById(R.id.textViewExchName);
    TextView textViewIntroName = (TextView) layout.findViewById(R.id.textViewIntroName);
    ImageView imageViewIntroPhoto = (ImageView) layout.findViewById(R.id.imageViewIntroPhoto);
    ad.setTitle(R.string.title_SecureIntroductionInvite);
    textViewExchName.setText(exchName);
    textViewIntroName.setText(introName);
    if (introPhoto != null) {
        try {
            Bitmap bm = BitmapFactory.decodeByteArray(introPhoto, 0, introPhoto.length, null);
            imageViewIntroPhoto.setImageBitmap(bm);
        } catch (OutOfMemoryError e) {
            imageViewIntroPhoto.setImageDrawable(getResources().getDrawable(R.drawable.ic_silhouette));
        }
    }
    ad.setView(layout);
    ad.setCancelable(false);
    ad.setPositiveButton(getString(R.string.btn_Accept), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

            // accept secure introduction?
            int selected = 0;
            args.putString(extra.NAME + selected, introName);
            args.putByteArray(extra.PHOTO + selected, introPhoto);
            args.putByteArray(SafeSlingerConfig.APP_KEY_PUBKEY + selected, introPubKey);
            args.putByteArray(SafeSlingerConfig.APP_KEY_PUSHTOKEN + selected, introPush);

            String contactLookupKey = getContactLookupKeyByName(introName);
            args.putString(extra.CONTACT_LOOKUP_KEY + selected, contactLookupKey);

            MessageRow inviteMsg = null;
            MessageDbAdapter dbMessage = MessageDbAdapter.openInstance(getApplicationContext());
            Cursor c = dbMessage.fetchMessageSmall(msgRowId);
            if (c != null) {
                try {
                    if (c.moveToFirst()) {
                        inviteMsg = new MessageRow(c, false);
                    }
                } finally {
                    c.close();
                }
            }

            if (inviteMsg == null) {
                showNote(R.string.error_InvalidIncomingMessage);
                return;
            }

            // import the new contacts
            args.putInt(extra.RECIP_SOURCE, RecipientDbAdapter.RECIP_SOURCE_INTRODUCTION);
            args.putString(extra.KEYID, inviteMsg.getKeyId());
            ImportFromExchangeTask importFromExchange = new ImportFromExchangeTask();
            importFromExchange.execute(args);
            setTab(Tabs.MESSAGE);
            refreshView();
        }
    });
    ad.setNegativeButton(getString(R.string.btn_Refuse), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            showNote(String.format(getString(R.string.state_SomeContactsImported), 0));
            refreshView();
        }
    });
    return ad;
}