I am trying to get Uri of videos stored in my database so that i can get it as thumbnail, i have successfully converted it in the bitmap but i just cant seem to get Uri of that bitmap so i can display video thumbnail in my List using cursor at the back end. the following line shows Error that its provided by a null value.
Uri Uri1= Uri.parse(path);\\from__NEWS_Feedoverlay---class
please take a look in to the following code fragment
------------------------XXXXXXXXXXMethod from helper class------------------------------------------------------------------------
public Cursor getCursor()
{
String where=null;
db= this.getReadableDatabase();
//db.rawQuery("select image , name from images",null);
//Cursor cursor = db.rawQuery("select _id, name from images",null);
Cursor cursor= db.query(true,TABLE_Images,KEY,where,null,null,null,null,null,null);
if (cursor!=null)
{
cursor.moveToFirst();
}
return cursor;
------------------------------XXXXXXXXXXXX--NEWS_Feedoverlay---class---------------------
Cursor cursor = helper.getCursor();
startManagingCursor(cursor);
//setup for MApping in view fields
Uri myUri= Uri.parse(helper.KEY_IMAGE);
// Uri Uri1= MediaStore.Video.Thumbnails.getContentUri(helper.KEY_FILE);
Bitmap bMap = ThumbnailUtils.createVideoThumbnail(helper.KEY_FILE, MediaStore.Video.Thumbnails.MICRO_KIND);
String path = MediaStore.Images.Media.insertImage(getContentResolver(), bMap, "Title", null);
Uri Uri1= Uri.parse(path);
// ContentResolver crThumb = getContentResolver();
//Bitmap bitmap =MediaStore.Video.Thumbnails.getThumbnail(crThumb, Long.parseLong(helper.KEY_FILE),MediaStore.Video.Thumbnails.MICRO_KIND,null);
String [] fromFieldNames=new String[]{helper.KEY_NAME, String.valueOf(Uri1)};
int[] toViewID= new int[]{R.id.title,R.id.list_video};
SimpleCursorAdapter myadaptor= new SimpleCursorAdapter(this, R.layout.list_row, cursor,fromFieldNames,toViewID );
ListView mylist= (ListView)findViewById(R.id.list);
mylist.setAdapter(myadaptor);
------------------------------LOGCAT----------------------------
FATAL EXCEPTION: main
Process: com.example.sanya.ar_expeditor, PID: 2675
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sanya.ar_expeditor/com.example.sanya.ar_expeditor.NewsFeed_Viewoverlay}: java.lang.NullPointerException: uriString
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:475)
at android.net.Uri$StringUri.<init>(Uri.java:465)
at android.net.Uri.parse(Uri.java:437)
at com.example.sanya.ar_expeditor.NewsFeed_Viewoverlay.onCreate(NewsFeed_Viewoverlay.java:48)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
maybe its the way i convert the video uri into thumbnails but either way its the same ERROR .. i have followed these following links Does anyone know what exactly m doing wrong n how to put it correct..??? thanks... How to get the video thumbnail path, and not the bitmap Android: Is it possible to display video thumbnails?