I forgot in the same class, I start intents :

   // Pick contact information from contacts list
   Intent i = new Intent(Intent.ACTION_GET_CONTENT);
   i.setType("image/*");
   startActivityForResult(i, PICK_IMAGE);

   // Pick image from gallery
   Intent intent = new Intent(Intent.ACTION_PICK,
People.CONTENT_URI);
   startActivityForResult(intent, PICK_CONTACT);


On 10 déc, 10:23, Tom <thomas.coz...@gmail.com> wrote:
> This is the solution :
>
> in the activity class, I change onActivityResult method to handle
> picking contact and picking image fromgallery.
>
>     private static final int PICK_CONTACT = 0;
>     private static final int PICK_IMAGE = 1;
>
>     @Override
>     public void onActivityResult(int reqCode, int resultCode, Intent
> data) {
>         super.onActivityResult(reqCode, resultCode, data);
>
>         switch (reqCode) {
>             case (PICK_CONTACT):
>                 if (resultCode == Activity.RESULT_OK) {
>                     Uri contactData = data.getData();
>                     Cursor c = managedQuery(contactData, null, null,
> null, null);
>                     if (c.moveToFirst()) {
>                         Bitmap photo  = People.loadContactPhoto(this,
> contactData, DEFAULT_IMAGE, null);
>                     }
>                 }
>                 break;
>
>             case (PICK_IMAGE):
>                 if (resultCode == Activity.RESULT_OK)
>                 {
>                         // the image is accessible via :
>                         data.getData();
>                 }
>                 break;
>         }
>     }
>
> On 1 déc, 17:48, Tom <thomas.coz...@gmail.com> wrote:
>
> > Thanks for your answer both of you...
>
> > I'm going to look at this now...
>
> > Best regards
> > Tom
>
> > On 1 déc, 16:22, Carmen Delessio <carmendeles...@gmail.com> wrote:
>
> > > Start the activity with startActivityForResult.  Then handle the returned
> > > data in onActivityResult.
> > > The source below is how I do it.  There should be enough here to get the
> > > photo data.
> > > Carmen
> > > --
> > > Carmenhttp://www.twitter.com/CarmenDelessiohttp://www.talkingandroid.comhtt...
>
> > > Call the Intent somewhere in your activity using startActivityForResult:
> > >                 Intent i = new Intent(Intent.ACTION_GET_CONTENT);
> > >                    i.setType("image/*");
> > >                 startActivityForResult(i,4); // activity id is 4
>
> > > // handle the activity
> > > // look at documentation for AssetFileDescriptor.  That is how I 
> > > ultimately
> > > got the photo
> > > //http://developer.android.com/reference/android/content/res/AssetFileD...
>
> > >    protected void  onActivityResult  (int requestCode, int resultCode,
> > > Intent data){
>
> > >              if (requestCode==4){  grab the result
> > >                  if (resultCode == RESULT_OK) {
> > >                      try {
> > >                      AssetFileDescriptor thePhoto =
> > > getContentResolver().openAssetFileDescriptor(data.getData(), "r");
> > >                      ...
>
> > >                      }
> > >                  }
> > >                  if (resultCode == RESULT_CANCELED) {
>
> > >                  }
> > >              }
>
> > > On Tue, Dec 1, 2009 at 9:44 AM, Streets Of Boston
> > > <flyingdutc...@gmail.com>wrote:
>
> > > > Take a look the the Intent framework.
> > > > Start an activity given an intent (PICK_IMAGE) and this should start
> > > > any app that responds to it (Galleryor some other 3rd party program).
>
> > > > For examples, just take a look at the Contacts application in
> > > > Android's framework's source-code.
>
> > > > On Dec 1, 4:28 am, Tom <thomas.coz...@gmail.com> wrote:
> > > > > Nobody?
>
> > > > > Tom
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to