SoundPool 在两种情况下会崩溃。第一个场景崩溃的代码
@Ian G. Clifton 这是我尝试的第一种类型的 soundpool 的代码。 当按钮加载活动时,程序会返回到上一个活动。
代码从此处开始,但不会传输::::::
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();
}
});
}
}
::::::::::::: 尝试过 soundpool 并收到错误日志::::::::::::::::
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
@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 doesn't 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现了我的问题。这部分代码没有问题。事实上,奇拉格·沙阿(Chirag Shah)通过他的建议让我找到了答案。我查看了我的代码,发现我已将按钮锁定在上一个活动中代码的创建部分之外。
我有
这是在 oncreate 方法之前但当我删除私有部分时。
现在工作正常了。
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
This was before the oncreate method but when I removed the private part.
now it works fine.
这可能有助于:
android soundpool 堆大小溢出
May this help about :
android soundpool heapsize overflow