Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

public void createMiniKeyboard() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mMiniKeyboard = (AnyKeyboardBaseView) inflater.inflate(R.layout.popup_keyboard_layout, null);

    mMiniKeyboard.setPopupParent(this);
    // hack: this will ensure that the key of a popup is no wider than a
    // thumb's width.
    ((KeyboardDimensFromTheme) mMiniKeyboard.getThemedKeyboardDimens())
            .setKeyMaxWidth(mMiniKeyboard.getThemedKeyboardDimens().getNormalKeyHeight());

    mMiniKeyboard.setOnKeyboardActionListener(new MiniKeyboardActionListener(this));
    // Override default ProximityKeyDetector.
    mMiniKeyboard.mKeyDetector = new MiniKeyboardKeyDetector(mMiniKeyboardSlideAllowance);
    // Remove gesture detector on mini-keyboard
    mMiniKeyboard.mGestureDetector = null;
}

From source file:me.ububble.speakall.fragment.ConversationChatFragment.java

public void checkCountryLocation(final boolean gpsProvider, final boolean netProvider) {
    getActivity().runOnUiThread(new Runnable() {
        @Override/*from  w  w w .ja v  a2 s  .  co m*/
        public void run() {
            boolean gpsEnabled = false;
            boolean networkEnabled = false;
            if (gpsProvider) {
                gpsEnabled = milocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            }
            if (netProvider) {
                networkEnabled = milocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
            }
            if (gpsProvider && netProvider) {
                if (!gpsEnabled && !networkEnabled) {
                    LayoutInflater dialogInflater = (LayoutInflater) activity
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    dialogView = dialogInflater.inflate(R.layout.null_contact_dialog, null);
                    TextView mensaje = (TextView) dialogView.findViewById(R.id.dialog_add_contact);
                    mensaje.setText(getString(R.string.location_services));
                    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity)
                            .setView(dialogView).setCancelable(true)
                            .setPositiveButton(R.string.add_contact_yes, null)
                            .setNegativeButton(R.string.add_contact_no, null);
                    finderDialog = dialogBuilder.show();
                    finderDialog.setCanceledOnTouchOutside(true);
                    finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                    System.gc();
                                    dontClose = true;
                                    ((MainActivity) activity).dontClose = true;
                                    hideKeyBoard();
                                    Intent intent = new Intent(
                                            android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                    startActivityForResult(intent, 45);
                                }
                            });
                    finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                }
                            });
                } else {
                    milocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            ConversationChatFragment.this);
                    milocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            ConversationChatFragment.this);
                }
            }
        }
    });
}

From source file:com.example.libwidgettv.bak.AbsListView.java

/**
 * Creates the window for the text filter and populates it with an EditText
 * field;//w ww .  j  ava2s  .  co m
 * 
 * @param animateEntrance
 *            true if the window should appear with an animation
 */
private void createTextFilter(boolean animateEntrance) {
    if (mPopup == null) {
        Context c = getContext();
        PopupWindow p = new PopupWindow(c);
        LayoutInflater layoutInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // mTextFilter = (EditText) layoutInflater.inflate(
        // com.android.internal.R.layout.typing_filter, null);
        mTextFilter = new EditText(getContext());
        // For some reason setting this as the "real" input type changes
        // the text view in some way that it doesn't work, and I don't
        // want to figure out why this is.
        mTextFilter.setRawInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER);
        mTextFilter.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        mTextFilter.addTextChangedListener(this);
        p.setFocusable(false);
        p.setTouchable(false);
        p.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        p.setContentView(mTextFilter);
        p.setWidth(LayoutParams.WRAP_CONTENT);
        p.setHeight(LayoutParams.WRAP_CONTENT);
        p.setBackgroundDrawable(null);
        mPopup = p;
        getViewTreeObserver().addOnGlobalLayoutListener(this);
        mGlobalLayoutListenerAddedFilter = true;
    }
    // if (animateEntrance) {
    // mPopup.setAnimationStyle(com.android.internal.R.style.Animation_TypingFilter);
    // } else {
    // mPopup.setAnimationStyle(com.android.internal.R.style.Animation_TypingFilterRestore);
    // }
}

From source file:com.appunite.list.AbsHorizontalListView.java

/**
 * Creates the window for the text filter and populates it with an EditText field;
 *
 * @param animateEntrance true if the window should appear with an animation
 *//*from w w  w  . ja v  a 2 s.  c om*/
private void createTextFilter(boolean animateEntrance) {
    if (mPopup == null) {
        Context c = getContext();
        PopupWindow p = new PopupWindow(c);
        LayoutInflater layoutInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mTextFilter = (EditText) layoutInflater.inflate(R.layout.typing_filter, null);
        // For some reason setting this as the "real" input type changes
        // the text view in some way that it doesn't work, and I don't
        // want to figure out why this is.
        mTextFilter.setRawInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER);
        mTextFilter.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        mTextFilter.addTextChangedListener(this);
        p.setFocusable(false);
        p.setTouchable(false);
        p.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        p.setContentView(mTextFilter);
        p.setWidth(LayoutParams.WRAP_CONTENT);
        p.setHeight(LayoutParams.WRAP_CONTENT);
        p.setBackgroundDrawable(null);
        mPopup = p;
        getViewTreeObserver().addOnGlobalLayoutListener(this);
        mGlobalLayoutListenerAddedFilter = true;
    }
    if (animateEntrance) {
        mPopup.setAnimationStyle(R.style.Animation_TypingFilter);
    } else {
        mPopup.setAnimationStyle(R.style.Animation_TypingFilterRestore);
    }
}

From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java

public void checkCountryLocation(final boolean gpsProvider, final boolean netProvider) {
    getActivity().runOnUiThread(new Runnable() {
        @Override//from www.  jav a 2s. co m
        public void run() {
            boolean gpsEnabled = false;
            boolean networkEnabled = false;
            if (gpsProvider) {
                gpsEnabled = milocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            }
            if (netProvider) {
                networkEnabled = milocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
            }
            if (gpsProvider && netProvider) {
                if (!gpsEnabled && !networkEnabled) {
                    LayoutInflater dialogInflater = (LayoutInflater) activity
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    dialogView = dialogInflater.inflate(R.layout.null_contact_dialog, null);
                    TextView mensaje = (TextView) dialogView.findViewById(R.id.dialog_add_contact);
                    mensaje.setText(getString(R.string.location_services));
                    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity)
                            .setView(dialogView).setCancelable(true)
                            .setPositiveButton(R.string.add_contact_yes, null)
                            .setNegativeButton(R.string.add_contact_no, null);
                    finderDialog = dialogBuilder.show();
                    finderDialog.setCanceledOnTouchOutside(true);
                    finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                    System.gc();
                                    dontClose = true;
                                    ((MainActivity) activity).dontClose = true;
                                    Intent intent = new Intent(
                                            android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                    startActivityForResult(intent, 45);
                                }
                            });
                    finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                }
                            });
                } else {
                    milocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            ConversationGroupFragment.this);
                    milocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            ConversationGroupFragment.this);
                }
            }
        }
    });
}

From source file:me.ububble.speakall.fragment.ConversationChatFragment.java

public void showDialogAddContact(final String contacto) {
    final boolean[] agregar = { false };
    try {/*  w  w w.j a  v  a  2 s.  co m*/
        final ContentResolver contentResolver = activity.getContentResolver();
        final JSONObject contact = new JSONObject(contacto);
        String name = null;
        String phone = null;

        String selectionArgs = ContactsContract.Contacts.DISPLAY_NAME + " = ? AND "
                + ContactsContract.CommonDataKinds.Phone.TYPE + "= "
                + ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE;

        Cursor c = contentResolver.query(ContactsContract.Data.CONTENT_URI,
                new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER }, selectionArgs,
                new String[] { contact.getString("nombre") }, null);

        if (c.getCount() > 0) {
            if (c.moveToFirst()) {
                phone = c.getString(0);
            }
            if (phone.equals(contact.getString("telefono"))) {
                Toast.makeText(activity, "Ya tienes este contacto", Toast.LENGTH_SHORT).show();
            } else {
                LayoutInflater dialogInflater = (LayoutInflater) activity
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                dialogView = dialogInflater.inflate(R.layout.add_contact_message, null);
                final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setView(dialogView)
                        .setCancelable(true).setPositiveButton(R.string.add_contact_yes, null)
                        .setNegativeButton(R.string.add_contact_no, null);
                finderDialog = dialogBuilder.show();
                finderDialog.setCanceledOnTouchOutside(true);
                finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                        .setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                try {
                                    finderDialog.dismiss();
                                    agregar[0] = true;
                                    if (agregar[0]) {
                                        ContentValues values = new ContentValues();
                                        values.put(ContactsContract.Data.DISPLAY_NAME,
                                                contact.getString("nombre"));
                                        Uri rawContactUri = contentResolver
                                                .insert(ContactsContract.RawContacts.CONTENT_URI, values);

                                        long rawContactId = ContentUris.parseId(rawContactUri);
                                        long contactId = ContentUris.parseId(rawContactUri);

                                        values.clear();
                                        values.put(ContactsContract.CommonDataKinds.Phone.NUMBER,
                                                contact.getString("telefono"));
                                        values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                                                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
                                        values.put(Data.RAW_CONTACT_ID, rawContactId);
                                        contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    }
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                        });
                finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                        .setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                finderDialog.dismiss();
                                agregar[0] = false;
                            }
                        });
            }
        } else {
            LayoutInflater dialogInflater = (LayoutInflater) activity
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            dialogView = dialogInflater.inflate(R.layout.add_contact_message, null);
            final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setView(dialogView)
                    .setCancelable(true).setPositiveButton(R.string.add_contact_yes, null)
                    .setNegativeButton(R.string.add_contact_no, null);
            finderDialog = dialogBuilder.show();
            finderDialog.setCanceledOnTouchOutside(true);
            finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                    .setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            try {
                                finderDialog.dismiss();
                                agregar[0] = true;
                                if (agregar[0]) {
                                    ContentValues values = new ContentValues();
                                    values.put(ContactsContract.Data.DISPLAY_NAME, contact.getString("nombre"));
                                    Uri rawContactUri = contentResolver
                                            .insert(ContactsContract.RawContacts.CONTENT_URI, values);

                                    long rawContactId = ContentUris.parseId(rawContactUri);

                                    values.clear();
                                    values.put(android.provider.ContactsContract.Data.MIMETYPE,
                                            ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.Phone.NUMBER,
                                            contact.getString("telefono"));
                                    values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                                            ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
                                    values.put(Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    values.clear();
                                    values.put(Data.MIMETYPE, ContactsContract.Data.CONTENT_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                                            contact.getString("nombre"));
                                    values.put(Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    values.clear();
                                    values.put(Data.MIMETYPE,
                                            ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                                            contact.getString("nombre"));
                                    values.put(Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    });
            finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                    .setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            finderDialog.dismiss();
                            agregar[0] = false;
                        }
                    });
        }
        c.close();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java

private void choosePicture() {
    if (cameraDialog == null) {
        LayoutInflater dialogInflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View dialogView = dialogInflater.inflate(R.layout.dialog_camera_gallery, null);
        TextView camera = (TextView) dialogView.findViewById(R.id.dialog_camera);
        TextView gallery = (TextView) dialogView.findViewById(R.id.dialog_gallery);
        TFCache.apply(activity, camera, TFCache.TF_SPEAKALL);
        TFCache.apply(activity, gallery, TFCache.TF_SPEAKALL);
        final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setView(dialogView)
                .setCancelable(true);//from  w  ww . j a  v a2s .  c  o m
        cameraDialog = dialogBuilder.show();
        camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cameraDialog.dismiss();
                dontClose = true;
                ((MainActivity) activity).dontClose = true;
                hideKeyBoard();
                File imagesFolder = new File(
                        Environment.getExternalStorageDirectory().getAbsolutePath() + "/SpeakOn/Image/Sent");
                imagesFolder.mkdirs();
                menuAdjunt = false;
                adjuntLayout.setVisibility(View.GONE);
                dateToCamera = Calendar.getInstance().getTimeInMillis();
                File image = new File(imagesFolder, dateToCamera + ".png");
                Uri uriSavedImage = Uri.fromFile(image);
                pictureActionIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                pictureActionIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
                startActivityForResult(pictureActionIntent, 23);
            }
        });
        gallery.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cameraDialog.dismiss();
                dontClose = true;
                ((MainActivity) activity).dontClose = true;
                hideKeyBoard();
                menuAdjunt = false;
                adjuntLayout.setVisibility(View.GONE);
                pictureActionIntent = new Intent(Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                startActivityForResult(pictureActionIntent, 1);
            }
        });
        cameraDialog.setCanceledOnTouchOutside(true);
    } else {
        cameraDialog.show();
    }
}

From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java

public void showDialogAddContact(final String contacto) {
    final boolean[] agregar = { false };
    try {/*from w w  w  .  jav a 2 s .  c o  m*/
        final ContentResolver contentResolver = activity.getContentResolver();
        final JSONObject contact = new JSONObject(contacto);
        String name = null;
        String phone = null;

        String selectionArgs = ContactsContract.Contacts.DISPLAY_NAME + " = ? AND "
                + ContactsContract.CommonDataKinds.Phone.TYPE + "= "
                + ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE;

        Cursor c = contentResolver.query(ContactsContract.Data.CONTENT_URI,
                new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER }, selectionArgs,
                new String[] { contact.getString("nombre") }, null);

        if (c.getCount() > 0) {
            if (c.moveToFirst()) {
                phone = c.getString(0);
            }
            if (phone.equals(contact.getString("telefono"))) {
                Toast.makeText(activity, "Ya tienes este contacto", Toast.LENGTH_SHORT).show();
            } else {
                LayoutInflater dialogInflater = (LayoutInflater) activity
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                dialogView = dialogInflater.inflate(R.layout.add_contact_message, null);
                final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setView(dialogView)
                        .setCancelable(true).setPositiveButton(R.string.add_contact_yes, null)
                        .setNegativeButton(R.string.add_contact_no, null);
                finderDialog = dialogBuilder.show();
                finderDialog.setCanceledOnTouchOutside(true);
                finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                        .setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                try {
                                    finderDialog.dismiss();
                                    agregar[0] = true;
                                    if (agregar[0]) {
                                        ContentValues values = new ContentValues();
                                        values.put(ContactsContract.Data.DISPLAY_NAME,
                                                contact.getString("nombre"));
                                        Uri rawContactUri = contentResolver
                                                .insert(ContactsContract.RawContacts.CONTENT_URI, values);

                                        long rawContactId = ContentUris.parseId(rawContactUri);
                                        long contactId = ContentUris.parseId(rawContactUri);

                                        values.clear();
                                        values.put(ContactsContract.CommonDataKinds.Phone.NUMBER,
                                                contact.getString("telefono"));
                                        values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                                                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
                                        values.put(ContactsContract.Contacts.Data.RAW_CONTACT_ID, rawContactId);
                                        contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    }
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                        });
                finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                        .setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                finderDialog.dismiss();
                                agregar[0] = false;
                            }
                        });
            }
        } else {
            LayoutInflater dialogInflater = (LayoutInflater) activity
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            dialogView = dialogInflater.inflate(R.layout.add_contact_message, null);
            final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setView(dialogView)
                    .setCancelable(true).setPositiveButton(R.string.add_contact_yes, null)
                    .setNegativeButton(R.string.add_contact_no, null);
            finderDialog = dialogBuilder.show();
            finderDialog.setCanceledOnTouchOutside(true);
            finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                    .setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            try {
                                finderDialog.dismiss();
                                agregar[0] = true;
                                if (agregar[0]) {
                                    ContentValues values = new ContentValues();
                                    values.put(ContactsContract.Data.DISPLAY_NAME, contact.getString("nombre"));
                                    Uri rawContactUri = contentResolver
                                            .insert(ContactsContract.RawContacts.CONTENT_URI, values);

                                    long rawContactId = ContentUris.parseId(rawContactUri);

                                    values.clear();
                                    values.put(android.provider.ContactsContract.Data.MIMETYPE,
                                            ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.Phone.NUMBER,
                                            contact.getString("telefono"));
                                    values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                                            ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
                                    values.put(ContactsContract.Contacts.Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    values.clear();
                                    values.put(ContactsContract.Contacts.Data.MIMETYPE,
                                            ContactsContract.Data.CONTENT_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                                            contact.getString("nombre"));
                                    values.put(ContactsContract.Contacts.Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                    values.clear();
                                    values.put(ContactsContract.Contacts.Data.MIMETYPE,
                                            ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
                                    values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
                                            contact.getString("nombre"));
                                    values.put(ContactsContract.Contacts.Data.RAW_CONTACT_ID, rawContactId);
                                    contentResolver.insert(ContactsContract.Data.CONTENT_URI, values);

                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    });
            finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                    .setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            finderDialog.dismiss();
                            agregar[0] = false;
                        }
                    });
        }
        c.close();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}