Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Can't pick the correct phone number

Can't pick the correct phone number

Put your problem here if it does not fit any of the other categories.

Can't pick the correct phone number

Postby smobydick » Wed May 09, 2012 4:39 pm

Hello,

i'm coding some little functionalities for an sms application.
My trouble is here : i can go in contact list, choose a name, then click and the name + the phone number will go in the edit Text.
But when i want to take another contact, only the name in the edit text is changing, not the phone number !Some people said me i have an error in my request Uri . here's a part of my code :

Code: Select all
// Bouton contact
   public void onClick(View v) {

      switch (v.getId()) {

      case R.id.boutonContact:

         // on crée un nouvel intent qui appelera une activité secondaire et
         // qui aura pour action de selectionner une donnée
         Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
         // un setType pour indiquer que l'objet intent doit retourner un
         // type Contact
         intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
         // lancement de l'activité et attente d'un retour de type
         // PICK_CONTACT
         startActivityForResult(intent, PICK_CONTACT);

         break;

      }

   }

   // permet de recuperer ce que startActivityForResult à envoyé
   public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      super.onActivityResult(requestCode, resultCode, intent);

      
      
      
      
      Uri phoneUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
      String[] PHONES_PROJECTION = new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER };
      
      String  PHONE_SELECTION = null;
            
            
            
            
      if (requestCode == PICK_CONTACT) {
         // creation objet cursor pour analyser chaque enregistrements
               
         Cursor phones = managedQuery(phoneUri, PHONES_PROJECTION,
               PHONE_SELECTION, null,
               ContactsContract.CommonDataKinds.Phone.IS_PRIMARY
                     );
         phones.moveToFirst();
         
         Cursor cursor =  managedQuery(intent.getData(), null, null, null, null);
             cursor.moveToNext();
         // bouger le curseur à la position suivante
         // cursor.moveToNext();

         if (resultCode == RESULT_OK) {
            

            // retourne l'index de la colonne et jette un exception s'il
            // elle n'existe pas et retourne l'index de cette colonen en
            // string

            String numContact =
                  phones.getString(phones
                        .getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
      

              String name = cursor.getString(cursor
              .getColumnIndexOrThrow(
              ContactsContract.Contacts.DISPLAY_NAME));
             
            

            // recuperer valeur de name dans l'edit text
            ((TextView) findViewById(R.id.numero)).setText(String
                  .valueOf(name+"("+
                        numContact+")"));
            
            
         } else {
            Intent retour = new Intent(SmsActivity.this,
                  ContactsContract.Contacts.class);
            startActivity(retour);
            Log.e("RESULT_OK", "erreur");
            Toast.makeText(this, "opération annulée", Toast.LENGTH_SHORT)
                  .show();
         }
      }
   }



Problem n°2:
I dont know why but i cant start writing a message at the top left corner. Its starting in the middle ! why ? screenshot :
http://images4.hiboox.com/images/1912/0 ... c09d6b.png

Sorry for mistakes, i'm not english
Can you help ? thanks you
smobydick
Freshman
Freshman
 
Posts: 8
Joined: Sun Feb 05, 2012 3:19 pm

Top

Re: Can't pick the correct phone number

Postby smobydick » Wed May 09, 2012 6:06 pm

my xml

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/numero" />

        <EditText
            android:id="@+id/numero"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/message" />


    <EditText
         android:maxLength="2000"
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.21"
        android:inputType="textMultiLine" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/envoyer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/envoyer" />

    <Button
        android:id="@+id/boutonContact"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Répertoire" />

</LinearLayout>
smobydick
Freshman
Freshman
 
Posts: 8
Joined: Sun Feb 05, 2012 3:19 pm

Re: Can't pick the correct phone number

Postby smobydick » Sat May 12, 2012 6:06 pm

Please can you help me?
smobydick
Freshman
Freshman
 
Posts: 8
Joined: Sun Feb 05, 2012 3:19 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests