我在 Play 商店中的一个应用程序中遇到了奇怪的问题。问题是我根本无法复制这个问题。这是我的游戏商店日志猫。任何帮助或想法将不胜感激。大约有 9 份报告。有超过10000个活跃用户。
java.lang.StackOverflowError
at android.os.Message.obtain(Message.java:236)
at android.os.Handler.obtainMessage(Handler.java:247)
at android.media.MediaPlayer.postEventFromNative(MediaPlayer.java:1760)
at android.media.MediaPlayer.getDuration(Native Method)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal.nepalisongsandmore.PlayerActivity$10.onProgressChanged(PlayerActivity.java:300)
at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
at android.widget.ProgressBar.setMax(ProgressBar.java:775)
at android.widget.AbsSeekBar.setMax(AbsSeekBar.java:180)
at com.peshal....
这是 PlayerActivity.java 的代码
package com.peshal.nepalisongsandmore;
import java.io.IOException;
import java.util.ArrayList;
import com.actionbarsherlock.app.SherlockActivity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
public class PlayerActivity extends SherlockActivity {
MediaPlayer mediaPlayer = MediaPlayerSingleton.mediaPlayer;
NotificationManager mNotificationManager;
Button play;
Button forward;
Button rewind;
Button pause;
Button previous;
Button next;
ImageView img;
SeekBar seekBar;
String mediaType;
AnimationDrawable frameAnimation;
TextView textView;
int position;
ArrayList<String> urls;
String url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
frameAnimation = new AnimationDrawable();
img = (ImageView)findViewById(R.id.equalizer_anim);
textView = (TextView) findViewById(R.id.songinfo);
// new LoadEqualizer().execute();
if(mediaPlayer!=null) {
mediaPlayer.reset();
}
mediaType = getIntent().getExtras().getString("mediaType");
if(mediaType.equals("songs")) {
position = getIntent().getExtras().getInt("position");
urls = getIntent().getStringArrayListExtra("urls");
}
else if(mediaType.equals("radios")) {
url = getIntent().getExtras().getString("radioUrl");
//radioName = getIntent().getExtras().getString("radioName");
}
play = (Button)findViewById(R.id.play);
seekBar = (SeekBar)findViewById(R.id.seekBar1);
forward = (Button)findViewById(R.id.forward);
rewind = (Button)findViewById(R.id.rewind);
pause = (Button)findViewById(R.id.pause);
previous =(Button) findViewById(R.id.previous);
next=(Button) findViewById(R.id.next);
play.setVisibility(View.GONE);
pause.setVisibility(View.GONE);
previous.setVisibility(View.GONE);
next.setVisibility(View.GONE);
rewind.setVisibility(View.GONE);
forward.setVisibility(View.GONE);
textView.setText("Buffering..");
playMusic();
}
public void playMusic() {
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer1), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer2), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer3), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer4), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer5), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer6), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer7), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer8), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer9), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer10), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer11), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer12), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer13), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer14), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer15), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer16), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer17), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer18), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer19), 50);
frameAnimation.addFrame(getResources().getDrawable(R.drawable.equalizer20), 50);
frameAnimation.setOneShot(false);
img.setBackgroundDrawable(frameAnimation);
frameAnimation.start();
frameAnimation.stop();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
if(mediaType.equals("songs")) {
mediaPlayer.setDataSource(urls.get(position));
}
else if (mediaType.equals("radios")) {
mediaPlayer.setDataSource(url);
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new OnPreparedListener(){
@Override
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
frameAnimation.start();
if (mediaType.equals("songs")) {
rewind.setVisibility(View.VISIBLE);
forward.setVisibility(View.VISIBLE);
previous.setVisibility(View.VISIBLE);
next.setVisibility(View.VISIBLE);
seekBar.setMax(mediaPlayer.getDuration());
}
pause.setVisibility(View.VISIBLE);
textView.setText("");
}
});
pause.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view) {
mediaPlayer.pause();
frameAnimation.stop();
play.setVisibility(View.VISIBLE);
pause.setVisibility(View.GONE);
rewind.setVisibility(View.GONE);
forward.setVisibility(View.GONE);
}
});
play.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mediaPlayer.start();
frameAnimation.start();
play.setVisibility(View.GONE);
if (mediaType.equals("songs")) {
pause.setVisibility(View.VISIBLE);
rewind.setVisibility(View.VISIBLE);
forward.setVisibility(View.VISIBLE);
}
}
});
forward.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mediaPlayer.seekTo(mediaPlayer.getCurrentPosition() + 1000);
}
});
previous.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
if (position==0) {
position = urls.size() -2;
}
else {
position = position-2;
}
mediaPlayer.stop();
mediaPlayer.reset();
play.setVisibility(View.GONE);
pause.setVisibility(View.GONE);
previous.setVisibility(View.GONE);
next.setVisibility(View.GONE);
rewind.setVisibility(View.GONE);
forward.setVisibility(View.GONE);
getNextTrack();
}
});
next.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mediaPlayer.stop();
mediaPlayer.reset();
play.setVisibility(View.GONE);
pause.setVisibility(View.GONE);
previous.setVisibility(View.GONE);
next.setVisibility(View.GONE);
rewind.setVisibility(View.GONE);
forward.setVisibility(View.GONE);
getNextTrack();
}
});
rewind.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mediaPlayer.seekTo(mediaPlayer.getCurrentPosition() - 1000);
}
});
mediaPlayer.setOnCompletionListener(new OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.reset();
frameAnimation.stop();
if(mediaType.equals("songs")) {
getNextTrack();
}
}
});
mediaPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener(){
int state;
@Override
public void onBufferingUpdate(MediaPlayer mediaPlayer, int percent) {
seekBar.setProgress(mediaPlayer.getCurrentPosition());
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
state = tm.getCallState();
if(state==TelephonyManager.CALL_STATE_OFFHOOK|| state==TelephonyManager.CALL_STATE_RINGING) {
mediaPlayer.pause();
new CallHandler().execute();
}
}
});
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
seekBar.setMax(mediaPlayer.getDuration());
if(fromUser){
mediaPlayer.seekTo(progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
Intent intent;
NotificationManager notificationManager;
@Override
protected void onPause() {
if(MediaPlayerSingleton.mediaPlayer.isPlaying()) {
notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
intent = new Intent(getApplicationContext(), PlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pIntent = PendingIntent.getActivity(getBaseContext(), 0, intent,0);
NotificationCompat.Builder noti =
new NotificationCompat.Builder(this)
.setSmallIcon(android.R.drawable.ic_media_play)
.setContentTitle("Nepali Music And more")
.setContentText("Playing");
noti.setContentIntent(pIntent);
noti.setAutoCancel(true);
noti.setOngoing(true);
Notification notification = noti.getNotification();
notificationManager.notify(1, notification);
}
super.onPause();
}
@Override
protected void onResume() {
if (notificationManager!=null) {
notificationManager.cancel(1);
}
super.onResume();
}
public void getNextTrack() {
if(mediaPlayer.isLooping()||mediaPlayer.isLooping()) {
mediaPlayer.reset();
}
if(position!=(urls.size()-1)) {
position = position + 1;
}
else{
position=0;
}
playMusic();
}
public class CallHandler extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
Log.d("New asynctask started", " Call handler");
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
while(tm.getCallState()==TelephonyManager.CALL_STATE_OFFHOOK|| tm.getCallState()==TelephonyManager.CALL_STATE_RINGING) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
mediaPlayer.start();
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.d("asynctask finished", " Call handler");
super.onPostExecute(result);
}
}
}