Example usage for android.content Intent getBooleanArrayExtra

List of usage examples for android.content Intent getBooleanArrayExtra

Introduction

In this page you can find the example usage for android.content Intent getBooleanArrayExtra.

Prototype

public boolean[] getBooleanArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static boolean[] getBooleanArrayExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getBooleanArrayExtra(name);
}

From source file:anakiou.com.picontrol.service.OutputIntentService.java

private void handleControlAll(Intent intent) {
    boolean[] values = intent.getBooleanArrayExtra(Constants.EXTRA_CTRL_VALUE);

    List<Integer> results = outputService.setAllControls(values);

    if (results.isEmpty()) {
        deliverResultToReceiver(Constants.FAILURE_RESULT, getString(R.string.failed_to_send_control));
    }/* w w  w  .ja v a2  s  . com*/

    List<Output> fromDb = outputDAO.findAll();

    for (int i = 0; i < 8; i++) {
        Output o = fromDb.get(i);
        o.setOutputStatus(results.get(i));
        outputDAO.update(o);
    }
    deliverResultToReceiver(Constants.SUCCESS_RESULT, getString(R.string.control_sent));
}

From source file:com.misczak.joinmybridge.PhoneBookFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    Log.d(TAG, "onActivityResult");
    listView.invalidateViews();/*from   w  w  w  . j a v  a 2  s.  co  m*/

    UUID bridgeId;

    if (resultCode != Activity.RESULT_OK)
        return;

    if (requestCode == REQUEST_CALL) {
        boolean[] options = data.getBooleanArrayExtra(EXTRA_CALL_OPTIONS);
        bridgeId = (UUID) data.getSerializableExtra(EXTRA_BRIDGE_ID);

        Log.d(TAG, " onActivityResult arr: " + Arrays.toString(options));

        CallUtilities utils = new CallUtilities();

        phoneNumber = utils.getCompleteNumber(bridgeId, mBridgeList, options[0], options[1]);
        placePhoneCall(phoneNumber);

    }

    //Read the selected data from the contacts application
    if (requestCode == REQUEST_CONTACT) {
        Uri contactUri = data.getData();

        String[] queryFields = { ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                ContactsContract.CommonDataKinds.Phone.NUMBER };

        Cursor c = getActivity().getContentResolver().query(contactUri, queryFields, null, null, null);

        if (c.getCount() == 0) {
            c.close();
            return;
        }

        c.moveToFirst();
        int phoneNumberColumn = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
        int displayNameColumn = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
        String contactPhoneNumber = c.getString(phoneNumberColumn).trim();
        String contactDisplayName = c.getString(displayNameColumn);
        Log.d(TAG, contactDisplayName);
        Log.d(TAG, contactPhoneNumber);

        Intent i = new Intent(getActivity(), BridgeActivity.class);

        i.putExtra(BridgeFragment.EXTRA_BRIDGE_NAME, contactDisplayName);

        ImportUtilities iu = new ImportUtilities();
        String[] bridgeComponents = iu.getNumberArray(contactPhoneNumber);

        if (bridgeComponents[0] != null && !bridgeComponents[0].isEmpty()) {
            i.putExtra(BridgeFragment.EXTRA_BRIDGE_NUMBER, bridgeComponents[0]);
        }
        if (bridgeComponents[1] != null && !bridgeComponents[1].isEmpty()) {
            i.putExtra(BridgeFragment.EXTRA_PARTICIPANT_CODE, bridgeComponents[1]);
        }
        if (bridgeComponents[2] != null && !bridgeComponents[2].isEmpty()) {
            i.putExtra(BridgeFragment.EXTRA_HOST_CODE, bridgeComponents[2]);
        }
        if (bridgeComponents[3] != null && !bridgeComponents[3].isEmpty()) {
            i.putExtra(BridgeFragment.EXTRA_FIRST_TONE, bridgeComponents[3]);
        }
        if (bridgeComponents[4] != null && !bridgeComponents[4].isEmpty()) {
            i.putExtra(BridgeFragment.EXTRA_SECOND_TONE, bridgeComponents[4]);
        }
        startActivityForResult(i, 0);

    }

}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindIntentExtra(Object receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//from  w  ww.jav  a2 s .c o m
        IntentExtra intentExtra = field.getAnnotation(IntentExtra.class);
        if (intentExtra != null) {
            try {
                Intent intent = null;
                if (receiver instanceof Activity) {
                    intent = ((Activity) receiver).getIntent();
                } else if (receiver instanceof Fragment) {
                    intent = ((Fragment) receiver).getActivity().getIntent();
                }
                if (intent != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, intent.getBooleanExtra(intentExtra.value(), false));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, intent.getByteExtra(intentExtra.value(), (byte) 0));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, intent.getCharExtra(intentExtra.value(), '\u0000'));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, intent.getDoubleExtra(intentExtra.value(), 0.0d));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, intent.getFloatExtra(intentExtra.value(), 0.0f));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, intent.getIntExtra(intentExtra.value(), 0));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, intent.getLongExtra(intentExtra.value(), 0L));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, intent.getShortExtra(intentExtra.value(), (short) 0));
                    } else if (type == String.class) {
                        field.set(receiver, intent.getStringExtra(intentExtra.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, intent.getBooleanArrayExtra(intentExtra.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, intent.getByteArrayExtra(intentExtra.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, intent.getCharArrayExtra(intentExtra.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, intent.getDoubleArrayExtra(intentExtra.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, intent.getFloatArrayExtra(intentExtra.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, intent.getIntArrayExtra(intentExtra.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, intent.getLongArrayExtra(intentExtra.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, intent.getShortArrayExtra(intentExtra.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, intent.getStringArrayExtra(intentExtra.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, intent.getSerializableExtra(intentExtra.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, intent.getBundleExtra(intentExtra.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}