1

画像の URI があります。Android で写真として設定したいのですが、どうすればよいですか? ここに私の機能があります

        Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{id}, null);
            if(cursor.moveToNext())
            {

                    mContactName = cursor.getString(cursor.getColumnIndex((ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
                    mPhotoUri = Uri.withAppendedPath(result, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
                    mContactNumber = cursor.getString(cursor.getColumnIndex((ContactsContract.CommonDataKinds.Phone.NUMBER)));

                    Log.i("Dante", "ContactName = "+ mContactName  );
                    Log.i("Dante", "mContactNumber  ="+mContactNumber);
                    Log.i("Dante", " PhotoURI "+mPhotoUri );

            }


            ContentResolver cr = mContext.getContentResolver();
            int i = collagelistadaper.getItemPositon();
            ContentValues values = new ContentValues();   
            values.put(ContactsContract.Contacts.Photo.CONTENT_DIRECTORY,                                       Uri.fromFile(quiltFolder.listFiles()[i]).toString()); //ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValue(ContactsContract.Contacts.Photo.CONTENT_DIRECTORY, values);     
            Uri result1 = cr.insert(ContactsContract.Data.CONTENT_URI ,values);     
            // getContentResolver().update(mPhotoUri,values,null,null);             
        mPhotoUri = Uri.withAppendedPath(result,ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
4

1 に答える 1

5

これを試して、

Uri sendUri = Uri.fromFile(externalFile)
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
            intent.setDataAndType(sendUri, "image/jpg");
            intent.putExtra("mimeType", "image/jpg");
            startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
于 2013-01-24T09:41:20.893 に答える