I am making a MP3 player Android App. I want to start another activity from a ListView click that opens up the artist directory to show the songs from that one artist. I based my code off of the [Android tutorial][1].
This below is in my onCreate in ArtistList.java
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
Intent intent = new Intent(getApplicationContext(), SongList.class);
String artistSongPath = artistsList.get(position).get("artistPath");//gets artist SDcard path
System.out.println("artistSongPath = " + artistSongPath); //prints out correct path
intent.putExtra("A_S_PATH", artistSongPath); //puts the artistSongPath static A_S_Path
startActivity(intent); //start the intent
}
});
At the top of my ArtistList.java I have
public final static String A_S_PATH = "wecode.mp3playerapp.MESSAGE";
And in my SongList.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.song_list);
Intent intent = getIntent();
String path = intent.getStringExtra(ArtistList.A_S_PATH) + "/";
System.out.println(path);
try {
File fp = new File(path);
findArtistSongs(fp);
}catch(NullPointerException npe){
System.out.println("Could not find path.");
}
}
A_S_Path is null and I am not getting into my catch. Please help! This is my first app!!