Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:46:32+00:00 2026-06-14T06:46:32+00:00

I’m developing soundplayer app and when to run it on emulater it works but

  • 0

I’m developing soundplayer app and when to run it on emulater it works but it does not work on physical device. The error when to click icon to start, I got an error and abended. Could someone take a look this code?
here is the code.

SoundPlayList Activity@

public class SoundPlayList extends Activity {
public final static int PLAY_MUSIC = 0;
private ListView mListView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.soundplayerlist);

    mListView = (ListView)findViewById(R.id.listView1);

    SoundPlayerAdapter adapter = new SoundPlayerAdapter(this);
    mListView.setAdapter(adapter);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent,View view,int position,long id){
        ListView listView = (ListView)parent;

        String item = (String)listView.getItemAtPosition(position);
        Intent intent = new Intent(SoundPlayList.this, SoundPlayerActivity.class);
        intent.putExtra("id",parent.getItemIdAtPosition(position));
        intent.putExtra("name",item);
        startActivityForResult(intent,PLAY_MUSIC);

    }
    });

}

SoundPlayerAdapter@

public class SoundPlayerAdapter extends ArrayAdapter<String>{
    private ArrayList<Long> mMusicIds = new ArrayList<Long>();
    public SoundPlayerAdapter(Context context) {
        super(context, android.R.layout.simple_list_item_1);
        ContentResolver resolver = context.getContentResolver();
        Cursor cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null,null,null,null);
    while(cursor.moveToNext()){
        String name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
        long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media._ID));

        mMusicIds.add(id);

        this.add(name);

    }
    }
    public long getItemId(int position){
        return mMusicIds.get(position);

    }
}

}

log trace@

11-12 15:45:04.985: D/AndroidRuntime(5288): Shutting down VM
11-12 15:45:04.985: W/dalvikvm(5288): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
11-12 15:45:04.985: E/AndroidRuntime(5288): FATAL EXCEPTION: main
11-12 15:45:04.985: E/AndroidRuntime(5288): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.soundplayer/com.example.soundplayer.SoundPlayList}: java.lang.NullPointerException
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread.access$1500(ActivityThread.java:121)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.os.Looper.loop(Looper.java:130)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread.main(ActivityThread.java:3701)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at java.lang.reflect.Method.invokeNative(Native Method)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at java.lang.reflect.Method.invoke(Method.java:507)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at dalvik.system.NativeStart.main(Native Method)
11-12 15:45:04.985: E/AndroidRuntime(5288): Caused by: java.lang.NullPointerException
11-12 15:45:04.985: E/AndroidRuntime(5288):     at com.example.soundplayer.SoundPlayList$SoundPlayerAdapter.<init>(SoundPlayList.java:52)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at com.example.soundplayer.SoundPlayList.onCreate(SoundPlayList.java:29)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-12 15:45:04.985: E/AndroidRuntime(5288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
11-12 15:45:04.985: E/AndroidRuntime(5288):     ... 11 more
11-12 15:45:10.105: I/Process(5288): Sending signal. PID: 5288 SIG: 9
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:46:34+00:00Added an answer on June 14, 2026 at 6:46 am
    11-12 15:45:04.985: E/AndroidRuntime(5288): Caused by: java.lang.NullPointerException
    11-12 15:45:04.985: E/AndroidRuntime(5288): at com.example.soundplayer.SoundPlayList$SoundPlayerAdapter.(SoundPlayList.java:52)
    11-12 15:45:04.985: E/AndroidRuntime(5288): at com.example.soundplayer.SoundPlayList.onCreate(SoundPlayList.java:29)
    11-12 15:45:04.985: E/AndroidRuntime(5288): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-12 15:45:04.985: E/AndroidRuntime(5288): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    11-12 15:45:04.985: E/AndroidRuntime(5288): ... 11 more
    11-12 15:45:10.105: I/Process(5288): Sending signal. PID: 5288 SIG: 9
    

    According log information, please see SoundPlayList.java:29 file.

    EDIT:

    ContentResolver.query method may be return null. So you need NullPoint check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.