我的问题出现在MainActivity
应用程序在闹钟响起时崩溃,我还有另一项活动,其中闹钟效果很好。另一个奇怪的事情是整个应用程序包括MainActivity
只能在模拟器上正常工作但在设备上它停止响应,Logcat只显示java.lang.nosuchmethod
错误。调试停止光标:
mainAmStart.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), mainPIStart);
在android v2.3.3和4.1.2以及4.4.2的模拟器上测试过。 我已经挣扎了好几个小时并且经历了所有谷歌和stackoverflow但没有成功我知道周围有相关的问题,但我的情况似乎安静不同所以决定问一个问题
以下是MainActivity.class
,它完全适用于模拟器但在设备上崩溃
mainAmStart = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
mainAmStop = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent mainIntentStart = new Intent(context, MainStartService.class);
Intent mainIntentStop = new Intent(context, MainStopService.class);
mainPIStart = PendingIntent.getService(context, 1001,mainIntentStart, 0);
mainPIStop = PendingIntent.getService(context, 1002, mainIntentStop, 0);
mainAmStart.setExact(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), mainPIStart);
mainAmStop.setExact(AlarmManager.RTC_WAKEUP,
MainActivity.endTimeLong, mainPIStop);
prefs.edit().putBoolean("mainAmStart", true).commit();
prefs.edit().putBoolean("mainAmStop", true).commit();
以下是FajraActivity.class
,它在模拟器和设备上都很有用
fajraAMStart = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
fajraAMStop = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intentStart = new Intent(context, FajraStartService.class);
Intent intentStop = new Intent(context, FajraStopService.class);
fajraPIStart = PendingIntent.getService(context, 11, intentStart, 0);
fajraPIStop = PendingIntent.getService(context, 12, intentStop, 0);
fajraAMStart.setRepeating(AlarmManager.RTC_WAKEUP,
startTimeLong, AlarmManager.INTERVAL_DAY, fajraPIStart);
fajraAMStop.setRepeating(AlarmManager.RTC_WAKEUP,
endTimeLong, AlarmManager.INTERVAL_DAY, fajraPIStop);
prefs.edit().putBoolean("fajraAMStart", true).commit();
prefs.edit().putBoolean("fajraAMStop", true).commit();
logcat的
05-26 15:49:56.431: E/AndroidRuntime(12240): at com.Khalid.Lakhani.TimeBasedProfile.MainActivity$1.onClick(MainActivity.java:222)
05-26 15:49:56.437: W/ActivityManager(503): Force finishing activity com.Khalid.Lakhani.TimeBasedProfile/.MainActivity
05-26 15:49:56.679: V/WindowManager(503): Changing focus from Window{426820b8 u0 com.Khalid.Lakhani.TimeBasedProfile/com.Khalid.Lakhani.TimeBasedProfile.MainActivity} to Window{424d5ef8 u0 Application Error: com.Khalid.Lakhani.TimeBasedProfile}
05-26 15:49:56.683: I/WindowManager(503): Gaining focus: Window{424d5ef8 u0 Application Error: com.Khalid.Lakhani.TimeBasedProfile}
05-26 15:49:56.750: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:0) setConsumerName: Application Error: com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:56.751: D/AES(503): process : com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:56.752: D/AES(503): module : com.Khalid.Lakhani.TimeBasedProfile v1 (1.0)
05-26 15:49:56.753: D/AEE/LIBAEE(503): shell: raise_exp(2, 12240, -1361051648, com.Khalid.Lakhani.TimeBasedProfile, 0x0x63ae5278, 0x0x0)
05-26 15:49:56.776: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:0) setDefaultBufferSize: w=540, h=245
05-26 15:49:56.789: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:0) connect: api=2
05-26 15:49:56.789: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) setSynchronousMode: enabled=1
05-26 15:49:56.790: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) new GraphicBuffer needed
05-26 15:49:56.970: W/ActivityManager(503): Activity pause timeout for ActivityRecord{429cc5e0 u0 com.Khalid.Lakhani.TimeBasedProfile/.MainActivity}
05-26 15:49:56.977: I/SurfaceTexture(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x42847160,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
05-26 15:49:56.992: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) new GraphicBuffer needed
05-26 15:49:57.011: I/SurfaceTexture(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x42847160,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
05-26 15:49:57.019: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) new GraphicBuffer needed
05-26 15:49:57.034: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) new GraphicBuffer needed
05-26 15:49:57.045: I/SurfaceTexture(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x42847160,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
05-26 15:49:57.064: I/SurfaceTexture(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x42847160,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
05-26 15:49:57.561: V/ActivityManager(503): Stopping ActivityRecord{429cc5e0 u0 com.Khalid.Lakhani.TimeBasedProfile/.MainActivity}: nowVisible=false waitingVisible=true finishing=true
05-26 15:49:57.907: V/ActivityManager(503): Stopping ActivityRecord{429cc5e0 u0 com.Khalid.Lakhani.TimeBasedProfile/.MainActivity}: nowVisible=true waitingVisible=false finishing=true
05-26 15:49:57.907: V/ActivityManager(503): Ready to stop: ActivityRecord{429cc5e0 u0 com.Khalid.Lakhani.TimeBasedProfile/.MainActivity}
05-26 15:49:57.979: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) [queue] fps:15.93, dur:1004.45, max:395.54, min:5.05
05-26 15:49:58.022: I/BufferQueue(132): [Application Error: com.Khalid.Lakhani.TimeBasedProfile](this:0x428434e8,api:2) [release] fps:16.81, dur:1011.18, max:387.89, min:13.72
05-26 15:49:58.618: D/AEE/AED(12269): Process:com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:58.618: I/AEE/AED(12269): com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:58.719: D/AEE/AED(12269): Module:com.Khalid.Lakhani.TimeBasedProfile v1 (1.0)
05-26 15:49:58.719: I/AEE/AED(12269): com.Khalid.Lakhani.TimeBasedProfile v1 (1.0)
05-26 15:49:58.819: D/AEE/AED(12269): Backtrace:Process: com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:58.819: D/AEE/AED(12269): Package: com.Khalid.Lakhani.TimeBasedProfile v1 (1.0)
05-26 15:49:58.819: D/AEE/AED(12269): at com.Khalid.Lakhani.TimeBasedProfile.MainActivity$1.onClick(MainActivity.java:222)
05-26 15:49:58.819: I/AEE/AED(12269): Process: com.Khalid.Lakhani.TimeBasedProfile
05-26 15:49:58.819: I/AEE/AED(12269): Package: com.Khalid.Lakhani.TimeBasedProfile v1 (1.0)
05-26 15:49:58.819: I/AEE/AED(12269): at com.Khalid.Lakhani.TimeBasedProfile.MainActivity$1.onClick(MainActivity.java:222)