Note that there are some explanatory texts on larger screens.

plurals
  1. POList all the images on android device
    primarykey
    data
    text
    <p>I was trying to list all the images in android device with their paths since 14 hours straight but I wasn't able to .. It keeps giving me "java.lang.RuntimeException: Unable to start activity ComponentInfo" error.</p> <p>I don't understand why.. </p> <p>Any help?? </p> <pre><code>package com.example.allpicsexample; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.AdapterView.OnItemClickListener; /** * Displays images from an SD card. */ public class MainActivity extends Activity { /** * Cursor used to access the results from querying for images on the SD card. */ private Cursor cursor; /* * Column index for the Thumbnails Image IDs. */ private int columnIndex; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA)); System.out.println("the path is : "+filePath); } } </code></pre> <p>and here is the LogCat info:</p> <blockquote> <p>11-14 08:29:01.739: D/AndroidRuntime(16788): Shutting down VM 11-14 08:29:01.739: W/dalvikvm(16788): threadid=1: thread exiting with uncaught exception (group=0x40018578) 11-14 08:29:01.749: E/AndroidRuntime(16788): FATAL EXCEPTION: main 11-14 08:29:01.749: E/AndroidRuntime(16788): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.allpicsexample/com.example.allpicsexample.MainActivity}: java.lang.NullPointerException 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.os.Handler.dispatchMessage(Handler.java:99) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.os.Looper.loop(Looper.java:130) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread.main(ActivityThread.java:3687) 11-14 08:29:01.749: E/AndroidRuntime(16788): at java.lang.reflect.Method.invokeNative(Native Method) 11-14 08:29:01.749: E/AndroidRuntime(16788): at java.lang.reflect.Method.invoke(Method.java:507) 11-14 08:29:01.749: E/AndroidRuntime(16788): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 11-14 08:29:01.749: E/AndroidRuntime(16788): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 11-14 08:29:01.749: E/AndroidRuntime(16788): at dalvik.system.NativeStart.main(Native Method) 11-14 08:29:01.749: E/AndroidRuntime(16788): Caused by: java.lang.NullPointerException 11-14 08:29:01.749: E/AndroidRuntime(16788): at com.example.allpicsexample.MainActivity.onCreate(MainActivity.java:37) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 11-14 08:29:01.749: E/AndroidRuntime(16788): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 11-14 08:29:01.749: E/AndroidRuntime(16788): ... 11 more</p> </blockquote> <p>Here is the 2nd crash log after implementing Abhishek's code</p> <blockquote> <p>11-14 10:00:20.159: D/AndroidRuntime(19266): Shutting down VM 11-14 10:00:20.159: W/dalvikvm(19266): threadid=1: thread exiting with uncaught exception (group=0x40018578) 11-14 10:00:20.189: E/AndroidRuntime(19266): FATAL EXCEPTION: main 11-14 10:00:20.189: E/AndroidRuntime(19266): android.app.SuperNotCalledException: Activity {com.example.allpicsexample/com.example.allpicsexample.MainActivity} did not call through to super.onCreate() 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1617) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.os.Handler.dispatchMessage(Handler.java:99) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.os.Looper.loop(Looper.java:130) 11-14 10:00:20.189: E/AndroidRuntime(19266): at android.app.ActivityThread.main(ActivityThread.java:3687) 11-14 10:00:20.189: E/AndroidRuntime(19266): at java.lang.reflect.Method.invokeNative(Native Method) 11-14 10:00:20.189: E/AndroidRuntime(19266): at java.lang.reflect.Method.invoke(Method.java:507) 11-14 10:00:20.189: E/AndroidRuntime(19266): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 11-14 10:00:20.189: E/AndroidRuntime(19266): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 11-14 10:00:20.189: E/AndroidRuntime(19266): at dalvik.system.NativeStart.main(Native Method)</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload