的Soundpool崩溃两scenerios。 code为第一之情况崩溃 [英] SoundPool crashes in two scenerios. Code for first scenerio crashes
问题描述
@Ian G.克利夫顿这里是code为第一类的Soundpool的我试过了。
当按钮加载该活动的程序功能界别回previous活动。
code从这里开始,但它不过度::::::转移
公共类SoundManager类{ 私人的Soundpool mSoundPool;
私人的HashMap<整数,整数GT; mSoundPoolMap;
私人AudioManager mAudioManager;
私人语境mContext;
公共SoundManager类()
{ } 公共无效initSounds(上下文theContext){
mContext = theContext;
mSoundPool =新的Soundpool(16,AudioManager.STREAM_MUSIC,0);
mSoundPoolMap =新的HashMap<整数,整数GT;();
mAudioManager =(AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
} 公共无效addSound(INT指数,诠释SoundID)
{
mSoundPoolMap.put(索引,mSoundPool.load(mContext,SoundID,1));
} 公共无效playSound(INT指数){ INT streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(指数),streamVolume,streamVolume,1,0,1F);
} 公共无效playLoopedSound(INT指数){ INT streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(索引),streamVolume,streamVolume,1,-1,1F);
}}
:::::::::::::::::::活动:::::::::::::::::::::::::
活动{ 私人SoundManager类mSoundManager; 公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.nouns); mSoundManager =新SoundManager类();
mSoundManager.initSounds(getBaseContext()); mSoundManager.addSound(1,R.raw.age);
mSoundManager.addSound(2,R.raw.air);
mSoundManager.addSound(3,R.raw.anger);
mSoundManager.addSound(4,R.raw.animal);
mSoundManager.addSound(5,R.raw.answer);
mSoundManager.addSound(6,R.raw.apple);
mSoundManager.addSound(7,R.raw.area);
mSoundManager.addSound(8,R.raw.arm);
mSoundManager.addSound(9,R.raw.art);
mSoundManager.addSound(10,R.raw.atom);
mSoundManager.addSound(11,R.raw.baby);
mSoundManager.addSound(12,R.raw.lback);
mSoundManager.addSound(13,R.raw.ball);
mSoundManager.addSound(14,R.raw.band);
mSoundManager.addSound(15 R.raw.bank);
按钮onebutton =(按钮)this.findViewById(R.id.n1_button);
onebutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(1);
Toast.makeText(NounsActivity.this,年龄,
Toast.LENGTH_LONG).show();
}
});
按钮twobutton =(按钮)this.findViewById(R.id.n2_button);
twobutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(2);
Toast.makeText(NounsActivity.this,AIR,
Toast.LENGTH_LONG).show();
}
});
按钮threebutton =(按钮)this.findViewById(R.id.n3_button);
threebutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(3);
Toast.makeText(NounsActivity.this,愤怒,
Toast.LENGTH_LONG).show();
}
});
按钮fourbutton =(按钮)this.findViewById(R.id.n4_button);
fourbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(4);
Toast.makeText(NounsActivity.this,动物,
Toast.LENGTH_LONG).show();
}
});
按钮fivebutton =(按钮)this.findViewById(R.id.n5_button);
fivebutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(5);
Toast.makeText(NounsActivity.this,答案,
Toast.LENGTH_LONG).show();
}
});
按钮sixbutton =(按钮)this.findViewById(R.id.n6_button);
sixbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(6);
Toast.makeText(NounsActivity.this,苹果,
Toast.LENGTH_LONG).show();
}
});
按钮sevenbutton =(按钮)this.findViewById(R.id.n7_button);
sevenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(7);
Toast.makeText(NounsActivity.this,区域,
Toast.LENGTH_LONG).show();
}
});
按钮eightbutton =(按钮)this.findViewById(R.id.n8_button);
eightbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(8);
Toast.makeText(NounsActivity.this,ARM,
Toast.LENGTH_LONG).show();
}
});
按钮ninebutton =(按钮)this.findViewById(R.id.n9_button);
ninebutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){ mSoundManager.playSound(9);
Toast.makeText(NounsActivity.this,ART,
Toast.LENGTH_LONG).show();
}
});
按钮tenbutton =(按钮)this.findViewById(R.id.n10_button);
tenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(10);
Toast.makeText(NounsActivity.this,ATOM
Toast.LENGTH_LONG).show();
}
});
按钮elevenbutton =(按钮)this.findViewById(R.id.n11_button);
elevenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(11);
Toast.makeText(NounsActivity.this,宝贝,
Toast.LENGTH_LONG).show();
}
});
按钮twelvebutton =(按钮)this.findViewById(R.id.n12_button);
twelvebutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(12);
Toast.makeText(NounsActivity.this,BACK,
Toast.LENGTH_LONG).show();
}
});
按钮thirteenbutton =(按钮)this.findViewById(R.id.n13_button);
thirteenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(13);
Toast.makeText(NounsActivity.this,球,
Toast.LENGTH_LONG).show();
}
});
按钮fourteenbutton =(按钮)this.findViewById(R.id.n14_button);
fourteenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(14);
Toast.makeText(NounsActivity.this,带,
Toast.LENGTH_LONG).show();
}
});
按钮fifteenbutton =(按钮)this.findViewById(R.id.n15_button);
fifteenbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
mSoundManager.playSound(15);
Toast.makeText(NounsActivity.this,BANK
Toast.LENGTH_LONG).show();
}
});
键返回按钮=(按钮)this.findViewById(R.id.Back_Button);
Backbutton.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
完();
}
});
}
}
::::::::::::尝试的Soundpool,得到了错误日志:::::::::::::::
15 02-04:40:05.534:DEBUG / dalvikvm(471):试图加载的lib /system/lib/libsoundpool.so为0x0
02-04 15:40:05.613:DEBUG / dalvikvm(471):添加共享库/system/lib/libsoundpool.so为0x0
02-04 15:40:09.220:ERROR / AudioCache(172):堆大小溢出! REQ大小:1049856,最大尺寸:1048576
02-04 15:40:09.223:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.234:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.243:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.254:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.264:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.333:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.333:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.333:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.344:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.344:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.344:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.353:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.353:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.353:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.353:ERROR / AudioCache(172):堆大小溢出! REQ大小:1052672,最大尺寸:1048576
02-04 15:40:09.364:ERROR / AudioCache(172):堆大小溢出! REQ大小:1051392,最大尺寸:1048576
02-04 15:40:15.313:WARN / ActivityManager(179):启动超时已过期,放弃唤醒锁!
02-04 15:40:15.363:WARN / ActivityManager(179):活动空闲超时为HistoryRecord {43c86078 com.BluMouse.MNEKRENFULL2 / .NounsActivity}
02-04 15:40:17.943:DEBUG / AndroidRuntime(471):关闭VM
02-04 15:40:18.133:WARN / dalvikvm(471):主题ID = 3:螺纹未捕获的异常退出(组= 0x4001b188)
02-04 15:40:18.186:ERROR / AndroidRuntime(471):未捕获的处理程序:螺纹主力退出,由于未捕获的异常
02-04 15:40:19.433:ERROR / AndroidRuntime(471):了java.lang.RuntimeException:无法启动活动ComponentInfo {} package.nameActivity:显示java.lang.NullPointerException
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread.access $ 2200(ActivityThread.java:119)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1863)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.os.Handler.dispatchMessage(Handler.java:99)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.os.Looper.loop(Looper.java:123)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在java.lang.reflect.Method.invokeNative(本机方法)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在java.lang.reflect.Method.invoke(Method.java:521)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在dalvik.system.NativeStart.main(本机方法)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):致:显示java.lang.NullPointerException
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在package.nameActivity.onCreate(nameActivity.java:168)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
02-04 15:40:19.433:ERROR / AndroidRuntime(471):11 ...更多
02-04 15:40:19.573:信息/流程(179):发送信号。 PID:471 SIG:3
02-04 15:40:19.583:信息/ dalvikvm(471):主题ID = 7:反应信号3
02-04 15:40:21.363:信息/ dalvikvm(471):写堆栈跟踪/data/anr/traces.txt
02-04 15:40:29.603:DEBUG / dalvikvm(351):GC释放44的对象/在8302ms 2136字节
02-04 15:40:29.863:DEBUG / dalvikvm(227):GC释放2193对象/在1879ms 127504字节
我发现我的问题。这是不符合code的这些部分的问题。其实奇拉格沙阿导致我被他sudgestion答案。我通过code看了一下,发现我已锁定按钮出在previous活动code的创建段。
我
个人按钮按钮1;
这是onCreate方法之前,但是当我删除了私处。
按钮按钮1;
现在它工作正常。
@Ian G. Clifton Here is the code for the first type of soundpool I tried. when the button to load the activity the program FCs back to the previous activity.
code starts here but it doesnt' transfer over::::::
public class SoundManager {
private SoundPool mSoundPool;
private HashMap<Integer, Integer> mSoundPoolMap;
private AudioManager mAudioManager;
private Context mContext;
public SoundManager()
{
}
public void initSounds(Context theContext) {
mContext = theContext;
mSoundPool = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
mSoundPoolMap = new HashMap<Integer, Integer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
public void addSound(int Index,int SoundID)
{
mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));
}
public void playSound(int index) {
int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f);
}
public void playLoopedSound(int index) {
int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, -1, 1f);
}
}
:::::::::::::::::::activity:::::::::::::::::::::::::
Activity {
private SoundManager mSoundManager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nouns);
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, R.raw.age);
mSoundManager.addSound(2, R.raw.air);
mSoundManager.addSound(3, R.raw.anger);
mSoundManager.addSound(4, R.raw.animal);
mSoundManager.addSound(5, R.raw.answer);
mSoundManager.addSound(6, R.raw.apple);
mSoundManager.addSound(7, R.raw.area);
mSoundManager.addSound(8, R.raw.arm);
mSoundManager.addSound(9, R.raw.art);
mSoundManager.addSound(10, R.raw.atom);
mSoundManager.addSound(11, R.raw.baby);
mSoundManager.addSound(12, R.raw.lback);
mSoundManager.addSound(13, R.raw.ball);
mSoundManager.addSound(14, R.raw.band);
mSoundManager.addSound(15, R.raw.bank);
Button onebutton = (Button) this.findViewById(R.id.n1_button);
onebutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(1);
Toast.makeText(NounsActivity.this, "AGE",
Toast.LENGTH_LONG).show();
}
});
Button twobutton = (Button) this.findViewById(R.id.n2_button);
twobutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(2);
Toast.makeText(NounsActivity.this, "AIR",
Toast.LENGTH_LONG).show();
}
});
Button threebutton = (Button) this.findViewById(R.id.n3_button);
threebutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(3);
Toast.makeText(NounsActivity.this, "ANGER",
Toast.LENGTH_LONG).show();
}
});
Button fourbutton = (Button) this.findViewById(R.id.n4_button);
fourbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(4);
Toast.makeText(NounsActivity.this, "ANIMAL",
Toast.LENGTH_LONG).show();
}
});
Button fivebutton = (Button) this.findViewById(R.id.n5_button);
fivebutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(5);
Toast.makeText(NounsActivity.this, "ANSWER",
Toast.LENGTH_LONG).show();
}
});
Button sixbutton = (Button) this.findViewById(R.id.n6_button);
sixbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(6);
Toast.makeText(NounsActivity.this, "APPLE",
Toast.LENGTH_LONG).show();
}
});
Button sevenbutton = (Button) this.findViewById(R.id.n7_button);
sevenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(7);
Toast.makeText(NounsActivity.this, "AREA",
Toast.LENGTH_LONG).show();
}
});
Button eightbutton = (Button) this.findViewById(R.id.n8_button);
eightbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(8);
Toast.makeText(NounsActivity.this, "ARM",
Toast.LENGTH_LONG).show();
}
});
Button ninebutton = (Button) this.findViewById(R.id.n9_button);
ninebutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(9);
Toast.makeText(NounsActivity.this, "ART",
Toast.LENGTH_LONG).show();
}
});
Button tenbutton = (Button) this.findViewById(R.id.n10_button);
tenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(10);
Toast.makeText(NounsActivity.this, "ATOM",
Toast.LENGTH_LONG).show();
}
});
Button elevenbutton = (Button) this.findViewById(R.id.n11_button);
elevenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(11);
Toast.makeText(NounsActivity.this, "BABY",
Toast.LENGTH_LONG).show();
}
});
Button twelvebutton = (Button) this.findViewById(R.id.n12_button);
twelvebutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(12);
Toast.makeText(NounsActivity.this, "BACK",
Toast.LENGTH_LONG).show();
}
});
Button thirteenbutton = (Button) this.findViewById(R.id.n13_button);
thirteenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(13);
Toast.makeText(NounsActivity.this, "BALL",
Toast.LENGTH_LONG).show();
}
});
Button fourteenbutton = (Button) this.findViewById(R.id.n14_button);
fourteenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(14);
Toast.makeText(NounsActivity.this, "BAND",
Toast.LENGTH_LONG).show();
}
});
Button fifteenbutton = (Button) this.findViewById(R.id.n15_button);
fifteenbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(15);
Toast.makeText(NounsActivity.this, "BANK",
Toast.LENGTH_LONG).show();
}
});
Button Backbutton = (Button) this.findViewById(R.id.Back_Button);
Backbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();
}
});
}
}
::::::::::::tried soundpool and got error log:::::::::::::::
02-04 15:40:05.534: DEBUG/dalvikvm(471): Trying to load lib /system/lib/libsoundpool.so 0x0
02-04 15:40:05.613: DEBUG/dalvikvm(471): Added shared lib /system/lib/libsoundpool.so 0x0
02-04 15:40:09.220: ERROR/AudioCache(172): Heap size overflow! req size: 1049856, max size: 1048576
02-04 15:40:09.223: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.234: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.243: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.254: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.264: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.333: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.333: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.333: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.344: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.344: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.344: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.353: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.353: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.353: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.353: ERROR/AudioCache(172): Heap size overflow! req size: 1052672, max size: 1048576
02-04 15:40:09.364: ERROR/AudioCache(172): Heap size overflow! req size: 1051392, max size: 1048576
02-04 15:40:15.313: WARN/ActivityManager(179): Launch timeout has expired, giving up wake lock!
02-04 15:40:15.363: WARN/ActivityManager(179): Activity idle timeout for HistoryRecord{43c86078 com.BluMouse.MNEKRENFULL2/.NounsActivity}
02-04 15:40:17.943: DEBUG/AndroidRuntime(471): Shutting down VM
02-04 15:40:18.133: WARN/dalvikvm(471): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
02-04 15:40:18.186: ERROR/AndroidRuntime(471): Uncaught handler: thread main exiting due to uncaught exception
02-04 15:40:19.433: ERROR/AndroidRuntime(471): java.lang.RuntimeException: Unable to start activity ComponentInfo{package.nameActivity}: java.lang.NullPointerException
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:123)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:521)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): Caused by: java.lang.NullPointerException
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at package.nameActivity.onCreate(nameActivity.java:168)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
02-04 15:40:19.433: ERROR/AndroidRuntime(471): ... 11 more
02-04 15:40:19.573: INFO/Process(179): Sending signal. PID: 471 SIG: 3
02-04 15:40:19.583: INFO/dalvikvm(471): threadid=7: reacting to signal 3
02-04 15:40:21.363: INFO/dalvikvm(471): Wrote stack trace to '/data/anr/traces.txt'
02-04 15:40:29.603: DEBUG/dalvikvm(351): GC freed 44 objects / 2136 bytes in 8302ms
02-04 15:40:29.863: DEBUG/dalvikvm(227): GC freed 2193 objects / 127504 bytes in 1879ms
I found My problem. It is not a problem with these parts of the code. Actually Chirag Shah led me to the answer by his sudgestion. I looked through my code and found that I had locked the buttons out of the create section of the code in the previous activity.
I had
Private Button button1;
This was before the oncreate method but when I removed the private part.
Button button1;
now it works fine.
这篇关于的Soundpool崩溃两scenerios。 code为第一之情况崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!