Hi

Why I have this error, please ? It' s the same java code than the
following url:

http://developer.android.com/intl/fr/guide/topics/providers/content-providers.html


/
****************************************************************************/

package dany.android.databasejpeg;

import java.io.OutputStream;

import android.app.Activity;
import android.content.ContentValues;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.util.Log;

public class testjpeg extends Activity {
    private static final String TAG = null;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

     // Save the name and description of an image in a ContentValues
map.
        ContentValues values = new ContentValues(3);
        values.put(Media.DISPLAY_NAME, "road_trip_1");
        values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
        values.put(Media.MIME_TYPE, "image/jpeg");

        // Add a new record without the bitmap, but with the values
just set.
        // insert() returns the URI of the new record.

        Log.v(TAG, Media.EXTERNAL_CONTENT_URI.toString());

        Uri uri = getContentResolver().insert
(Media.EXTERNAL_CONTENT_URI, values);

        // Now get a handle to the file for that record, and save the
data into it.
        // Here, sourceBitmap is a Bitmap object representing the file
to save to the database.

        Bitmap sourceBitmap = BitmapFactory.decodeResource(getResources
(), R.drawable.test);

        try {
            OutputStream outStream = getContentResolver
().openOutputStream(uri);
            sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50,
outStream);
            outStream.close();
        } catch (Exception e) {
            Log.e(TAG, "exception while writing image: ", e);
        }
    }
}
/
****************************************************************************/



08-25 07:08:09.507: ERROR/DatabaseUtils(656): Writing exception to
parcel
08-25 07:08:09.507: ERROR/DatabaseUtils(656):
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
com.android.providers.media.MediaProvider.insertInternal
(MediaProvider.java:1139)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
com.android.providers.media.MediaProvider.insert(MediaProvider.java:
1118)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.content.ContentProvider$Transport.insert(ContentProvider.java:
140)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.content.ContentProviderNative.onTransact
(ContentProviderNative.java:125)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.os.Binder.execTransact(Binder.java:287)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
dalvik.system.NativeStart.run(Native Method)
08-25 07:08:09.536: DEBUG/AndroidRuntime(735): Shutting down VM
08-25 07:08:09.536: WARN/dalvikvm(735): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
08-25 07:08:09.536: ERROR/AndroidRuntime(735): Uncaught handler:
thread main exiting due to uncaught exception
08-25 07:08:09.546: ERROR/AndroidRuntime(735):
java.lang.RuntimeException: Unable to start activity ComponentInfo
{dany.android.databasejpeg/dany.android.databasejpeg.testjpeg}:
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.os.Handler.dispatchMessage(Handler.java:99)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.os.Looper.loop(Looper.java:123)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
java.lang.reflect.Method.invokeNative(Native Method)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
java.lang.reflect.Method.invoke(Method.java:521)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
dalvik.system.NativeStart.main(Native Method)
08-25 07:08:09.546: ERROR/AndroidRuntime(735): Caused by:
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.database.DatabaseUtils.readExceptionFromParcel
(DatabaseUtils.java:131)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.database.DatabaseUtils.readExceptionFromParcel
(DatabaseUtils.java:111)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.content.ContentProviderProxy.insert(ContentProviderNative.java:
340)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.content.ContentResolver.insert(ContentResolver.java:476)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
dany.android.databasejpeg.testjpeg.onCreate(testjpeg.java:34)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     ... 11 more


I think is not a problem of permission it's why i dont use permission
into my androidmanifest.xml

Or maybe i have to use :

 <uses-permission
android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>

or an other so what permission i have to use ??

Dany


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

Reply via email to