这是我的代码:
Intent i= getIntent(); // gets the previously created intent
Log.d(LOG_TAG, "PodcastSong (1):"+i.getStringExtra("PodcastSong"));
m_PodcastSong = i.getStringExtra("PodcastSong");
Log.d(LOG_TAG, "m_PodcastSong (1):"+m_PodcastSong);
btnPodcast_grey.setVisibility(View.VISIBLE);
btnOnAir_grey.setVisibility(View.GONE);
btnPlayPodcast.setEnabled(false);
btnPodcast_grey.setEnabled(false);
ShowProgressDialog Task = new ShowProgressDialog();
Task.execute();
ListenNowTimer();
}
catch (Throwable t) {
Log.e(LOG_TAG, "OnCreate-Error:" + t.getMessage(), t);
}
}
public static void RunPlaylist(int intPosition){
try
{
Log.d(LOG_TAG, "RunPlaylist");
Log.d(LOG_TAG, Integer.toString(intPosition));
relaxResources_Podcast();
if (mp_Podcast==null){
Log.d(LOG_TAG, "Create Media Player (Podcast) - yes");
mp_Podcast = new MediaPlayer();
}else{
Log.d(LOG_TAG, "Create Media Player (Podcast) - no");
}
mState_Podcast=State.Retrieving;
PodcastList.clear();
PodcastList = getPlayList();
SetPodcastLayout();
SetPodcastPlayLayout();
playSong(intPosition);
blnListenNow=false;
}
catch (Throwable t) {
Log.e(LOG_TAG, "RunPlaylist-Error:" + t.getMessage(), t);
}
}
public static void RunListenNow(String strPodcastSong){
try
{
Log.d(LOG_TAG, "RunListenNow");
Log.d(LOG_TAG, strPodcastSong);
relaxResources_Podcast();
Log.d(LOG_TAG, "after relaxResources_Podcast");
if (mp_Podcast==null){
Log.d(LOG_TAG, "Create Media Player (Podcast) - yes");
mp_Podcast = new MediaPlayer();
}else{
Log.d(LOG_TAG, "Create Media Player (Podcast) - no");
}
mHandler.removeCallbacks(mUpdateTimeTask);
//Add song into playlist
mState_Podcast=State.Retrieving;
PodcastList.clear();
PopulateListenNow(strPodcastSong);
SetPodcastLayout();
SetPodcastPlayLayout();
playSong_ListenNow(0);
blnListenNow=true;
btnNext.setEnabled(false);
btnPrevious.setEnabled(false);
btnPlayPodcast.setEnabled(true);
btnPodcast_grey.setEnabled(true);
}
catch (Throwable t) {
Log.e(LOG_TAG, "RunListenNow-Error:" + t.getMessage(), t);
}
}
private void ListenNowTimer(){
try{
//mProgress.setVisibility(View.VISIBLE);
tmrListenNow = new Timer();
tmrListenNow.scheduleAtFixedRate(new TimerTask() {
public void run() {
ListenNowHandler.sendEmptyMessage(0);
}
},10000,10000);
} catch (Throwable t) {
Log.e(LOG_TAG, "CheckMediaPlayerStatus-Error:" + t.getMessage(), t);
}
}
private Handler ListenNowHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
try{
//mProgress.setVisibility(View.GONE);
tmrListenNow.cancel();
tmrListenNow.purge();
mProgress.setVisibility(View.GONE);
//Generate list View from ArrayList
RunListenNow(m_PodcastSong);
}
catch (Throwable t) {
Log.e(LOG_TAG, "Process_Handler-Error:" + t.getMessage(), t);
//project_list.progressDialog.dismiss();
}
}
};
public static void PopulateListenNow(String strPodcastSong){
try
{
Log.e(LOG_TAG, "String Podcast Song :"+strPodcastSong);
mHandler.removeCallbacks(mUpdateTimeTask);
Log.e(LOG_TAG, "error1 :");
String[] arrSong = strPodcastSong.split("~");
Log.e(LOG_TAG, "error2 :");
HashMap<String, String> song = new HashMap<String, String>();
song.put("Podcast_id", arrSong[0]);
song.put("Title", arrSong[1]);
song.put("Prog_Name", arrSong[2]);
song.put("file_name", arrSong[3]);
song.put("duration", arrSong[4]);
song.put("Path", arrSong[5]);
song.put("desc", arrSong[6]);
song.put("image_url", arrSong[7]);
Log.e(LOG_TAG, "error1 :");
PodcastList.add(song);
}
catch (Throwable t) {
Log.e(LOG_TAG, "PopulateListenNow-Error:" + t.getMessage(), t);
}
}
以下是错误:
08-02 11:51:29.542: E/Player_listen_now(16044): PopulateListenNow-Error:length=7; index=7
08-02 11:51:29.542: E/Player_listen_now(16044): java.lang.ArrayIndexOutOfBoundsException: length=7; index=7
08-02 11:51:29.542: E/Player_listen_now(16044): at com.m3tech.bfm.Player_listen_now.PopulateListenNow(Player_listen_now.java:563)
08-02 11:51:29.542: E/Player_listen_now(16044): at com.m3tech.bfm.Player_listen_now.RunListenNow(Player_listen_now.java:466)
08-02 11:51:29.542: E/Player_listen_now(16044):
这是诸如 ipod 之类的应用程序...当我想在用户单击播放图标后播放播客时出现错误...但它仅适用于某些文件/歌曲...我无法识别代码或数据库中的问题。