正如标题所说..我的应用程序加载并运行良好,直到我点击admob广告..广告在浏览器或播放商店中加载但返回时,当我按下我唯一的图像按钮时,应用程序强制关闭..任何想法为什么?
05-21 14:52:12.060: D/dalvikvm(5403): GC_FOR_ALLOC freed 605K, 27% free 3581K/4867K, paused 21ms
05-21 14:52:12.065: I/dalvikvm-heap(5403): Grow heap (frag case) to 4.467MB for 614416-byte allocation
05-21 14:52:12.110: D/dalvikvm(5403): GC_CONCURRENT freed <1K, 15% free 4181K/4867K, paused 1ms+1ms
05-21 14:52:12.165: D/dalvikvm(5403): GC_FOR_ALLOC freed 0K, 15% free 4181K/4867K, paused 20ms
05-21 14:52:12.170: I/dalvikvm-heap(5403): Grow heap (frag case) to 5.786MB for 1382416-byte allocation
05-21 14:52:12.195: D/dalvikvm(5403): GC_CONCURRENT freed 0K, 12% free 5531K/6275K, paused 1ms+1ms
05-21 14:52:12.320: D/dalvikvm(5403): GC_FOR_ALLOC freed 600K, 21% free 5461K/6851K, paused 19ms
05-21 14:52:12.320: I/dalvikvm-heap(5403): Grow heap (frag case) to 6.875MB for 1213072-byte allocation
05-21 14:52:12.345: D/dalvikvm(5403): GC_CONCURRENT freed <1K, 18% free 6645K/8067K, paused 2ms+1ms
05-21 14:52:12.385: D/dalvikvm(5403): GC_FOR_ALLOC freed 526K, 18% free 6645K/8067K, paused 10ms
05-21 14:52:12.390: I/dalvikvm-heap(5403): Grow heap (frag case) to 8.027MB for 1210264-byte allocation
05-21 14:52:12.405: D/dalvikvm(5403): GC_FOR_ALLOC freed <1K, 16% free 7826K/9283K, paused 12ms
05-21 14:52:12.535: I/dalvikvm(5403): threadid=3: reacting to signal 3
05-21 14:52:12.555: I/dalvikvm(5403): Wrote stack traces to '/data/anr/traces.txt'
05-21 14:52:12.625: I/Ads(5403): To get test ads on this device, call adRequest.addTestDevice("1************************4");
05-21 14:52:12.665: I/Ads(5403): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":0,"session_id":"7866093980682069803","u_sd":1.5,"seq_num":"1","slotname":"********************","u_w":320,"msid":"com.spookytorch.jembe","js":"afma-sdk-a-v6.0.1","mv":"8011019.com.android.vending","isu":"1BAF8DE657D89B41C6CF3E83DEBFEC44","cipa":1,"format":"320x50_mb","net":"wi","app_name":"1.android.com.spookytorch.jembe","hl":"en","u_h":533,"carrier":"23430","ptime":0,"u_audio":1});</script></head><body></body></html>
05-21 14:52:12.690: W/Ads(5403): loadAd called while the ad is already loading, so aborting.
05-21 14:52:13.035: I/dalvikvm(5403): threadid=3: reacting to signal 3
05-21 14:52:13.040: I/dalvikvm(5403): Wrote stack traces to '/data/anr/traces.txt'
05-21 14:52:13.950: I/Ads(5403): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?kw&preqs=0&session_id=7866093980682069803&u_sd=1.5&slotname=a14fb9560894352&u_w=320&msid=com.spookytorch.jembe&js=afma-sdk-a-v6.0.1&mv=8011019.com.android.vending&isu=1BAF8DE657D89B41C6CF3E83DEBFEC44&cipa=1&format=320x50_mb&net=wi&app_name=1.android.com.spookytorch.jembe&hl=en&u_h=533&carrier=23430&ptime=0&u_audio=1&u_so=p&output=html®ion=mobile_app&u_tz=-60&ex=1&client_sdk=1&kw_type=broad&caps=inlineVideo_interactiveVideo_mraid1_clickTracking_sdkAdmobApiForAds&jsv=24" type: "admob" afmaNotifyDt: "null">
05-21 14:52:14.645: I/Ads(5403): onReceiveAd()
05-21 14:52:17.980: I/Ads(5403): onPresentScreen()
05-21 14:52:17.980: I/Ads(5403): onLeaveApplication()
05-21 14:52:18.025: D/dalvikvm(5403): GC_FOR_ALLOC freed 2417K, 30% free 7017K/9923K, paused 18ms
05-21 14:52:18.025: W/MediaPlayer-JNI(5403): MediaPlayer finalized without being released
05-21 14:52:18.030: W/CursorWrapperInner(5403): Cursor finalized without prior close()
05-21 14:52:18.075: D/webviewglue(5403): nativeDestroy view: 0x19576e0
05-21 14:52:18.080: D/webviewglue(5403): nativeDestroy view: 0x19a5bd8
05-21 14:52:21.000: I/Ads(5403): onDismissScreen()
05-21 14:52:21.835: I/info(5403): torch is turn on!
05-21 14:52:21.840: D/AndroidRuntime(5403): Shutting down VM
05-21 14:52:21.840: W/dalvikvm(5403): threadid=1: thread exiting with uncaught exception (group=0x40a4a1f8)
05-21 14:52:21.850: E/AndroidRuntime(5403): FATAL EXCEPTION: main
05-21 14:52:21.850: E/AndroidRuntime(5403): java.lang.RuntimeException: Method called after release()
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.hardware.Camera.native_setParameters(Native Method)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.hardware.Camera.setParameters(Camera.java:1423)
05-21 14:52:21.850: E/AndroidRuntime(5403): at com.spookytorch.jembe.SpookyTorch$1.onClick(SpookyTorch.java:118)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.view.View.performClick(View.java:3511)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.view.View$PerformClick.run(View.java:14105)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.os.Handler.handleCallback(Handler.java:605)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.os.Handler.dispatchMessage(Handler.java:92)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.os.Looper.loop(Looper.java:137)
05-21 14:52:21.850: E/AndroidRuntime(5403): at android.app.ActivityThread.main(ActivityThread.java:4575)
05-21 14:52:21.850: E/AndroidRuntime(5403): at java.lang.reflect.Method.invokeNative(Native Method)
05-21 14:52:21.850: E/AndroidRuntime(5403): at java.lang.reflect.Method.invoke(Method.java:511)
05-21 14:52:21.850: E/AndroidRuntime(5403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-21 14:52:21.850: E/AndroidRuntime(5403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-21 14:52:21.850: E/AndroidRuntime(5403): at dalvik.system.NativeStart.main(Native Method)
{Java 文件}
//flag to detect flash is on or off
private boolean isLighOn = false;
boolean check=false;
private Camera camera;
private ImageButton button;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
finish();
android.os.Process.killProcess(android.os.Process.myPid()) ;
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onStop() {
super.onStop();
if (camera != null) {
camera.release();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//--------------------------------------------------------------\\
final MediaPlayer mp = MediaPlayer.create(this, R.raw.rain);
final MediaPlayer mp1 = MediaPlayer.create(this, R.raw.scream);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
button = (ImageButton) findViewById(R.id.buttonFlashlight);
mp.start();
Context context = this;
PackageManager pm = context.getPackageManager();
// if device support camera?
if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
Log.e("err", "Device has no camera!");
return;
}
camera = Camera.open();
final Parameters p = camera.getParameters();
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if (isLighOn) {
Log.i("info", "torch is turn off!");
p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);
camera.stopPreview();
isLighOn = false;
} else {
Log.i("info", "torch is turn on!");
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);
camera.startPreview();
isLighOn = true;
mp1.start();
}
}
});
}
}