- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
过去几天我注意到推送通知中有奇怪的行为。收到推送通知后,我可以单击它来打开应用程序。它工作正常,直到随机,由于某种原因,在单击应用程序想要打开的推送通知后,但完全挂起。结果是黑屏和 ANR。该应用程序需要强制关闭。
我花了几个小时才找到原因。我发现了一件奇怪的事情。当我从manifest.xml 中删除Google Ads Activity 条目后,一切似乎都正常工作。当然,广告除外。现在我记得几周前我已将 Google Play 服务更新至修订版 14。
我的 list 如下所示:
<activity
android:name="soccer.MainActivity"
android:label="@string/Voetbal" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
从 onreceive 中的广播接收器我有以下代码
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra("matchid", matchid);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN){
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
} else{
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
intent.setData(Uri.parse("content://"+when));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager notificationManager =(NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
context.getApplicationContext())
.setWhen(when)
.setContentText(notificationContent)
.setContentTitle(notificationTitle)
.setSmallIcon(smalIcon)
.setAutoCancel(true)
.setTicker(notificationTitle)
//.setLargeIcon(largeIcon)
.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND)
.setContentIntent(pendingIntent);
Notification notification=notificationBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
try {
notificationManager.notify(Integer.parseInt(matchid), notification);
;
} catch (NumberFormatException e) {
notificationManager.notify(0, notification);
}
我绝对确信,当我删除 Google 广告 Activity 后,问题就消失了。我不知道发生了什么事。难道android正在尝试启动广告 Activity 而不是MainActivity。当问题发生时,“onCreate”也不会被调用。
我深入研究了 ANR 后生成的 traces.txt 文件。它是一个巨大的文件,但它开头为:
JNI: CheckJNI is off; workarounds are off; pins=0; globals=302 (plus 121 weak)
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 MONITOR
| group="main" sCount=1 dsCount=0 obj=0x41b3cca8 self=0x41b2b3c8
| sysTid=26971 nice=-6 sched=0/0 cgrp=apps handle=1074516308
| state=S schedstat=( 0 0 0 ) utm=302 stm=78 core=0
at aal.b(SourceFile:~287)
- waiting to lock <0x42a2af28> (a java.lang.Object) held by tid=16 (AdWorker #1)
at abm.f(SourceFile:33)
at xq.r(SourceFile:593)
at xq.b(SourceFile:168)
at ya.onTransact(SourceFile:59)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.internal.ac$a$a.destroy((null):-1)
←[7m--more--←[0m
at com.google.android.gms.ads.AdView.destroy((null):-1)
at soccer.ContainerFragmentMatchInfo.onDestroy(ContainerFragmentMatchInfo.java:93)
at android.support.v4.app.Fragment.performDestroy(Fragment.java:1720)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1056)
at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1201)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:639)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:456)
at com.actionbarsherlock.app.SherlockFragmentActivity.onPostResume(SherlockFragmentActivity.java:68)
at android.app.Activity.performResume(Activity.java:5323)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
更新::
如果我从应用程序中删除以下代码,一切似乎都会再次正常工作:
@Override
public void onPause() {
adView.pause();
super.onPause();
}
@Override
public void onResume() {
super.onResume();
adView.resume();
}
@Override
public void onDestroy() {
adView.destroy();
super.onDestroy();
}
我不知道为什么。我不知道影响是什么。
最佳答案
正如您在 Android 文档中看到的那样(例如 here ),对于所有生命周期方法,您应该始终首先调用父类(super class)方法。
在父类(super class)方法之前调用 adView
方法可能是导致问题的原因。
@Override
public void onPause() {
super.onPause(); // Always call the superclass method first
// Release the Camera because we don't need it when paused
// and other activities might need to use it.
if (mCamera != null) {
mCamera.release()
mCamera = null;
}
}
因此,您可以将其更改为:
,而不是删除该代码 @Override
public void onPause() {
super.onPause();
adView.pause();
}
@Override
public void onResume() {
super.onResume();
adView.resume();
}
@Override
public void onDestroy() {
super.onDestroy();
adView.destroy();
}
关于android - 从推送通知打开应用程序会挂起应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21454546/
我有一个应用程序,当通过 eclipse 运行时,它会导致 eclipse 本身挂起。如果我将此应用程序导出为 jar 并运行它,它工作正常。但是,如果我运行(或调试)它,应用程序将显示为启动(根据
我正在将项目从 Rails2 切换到 Rails3。我跑: rails server 服务器启动没有错误: => Booting WEBrick => Rails 3.0.7 application
当我尝试使用 XCode 打开特定项目时,它挂起。当它挂起时,它显示以下屏幕: 其他项目可以正常打开,虽然挂起的项目也打开了,意味着我什么也做不了。我的 CPU 全速运行(风扇开始运转),我必须退出多
我正在使用 BNHtmlPdfKit 将 Html 呈现为 PDF。它工作得很好,但在 iOS8 中它只是挂起 [renderer drawPageAtIndex:i inRect:renderer.
我一直在尝试在 eclipse 中创建一个项目,并且有一个名为 InitRemoteEditJob 的工作正在阻止一切。它甚至没有被取消。 请建议怎么办? 最佳答案 这个错误有很多原因。 你可以试试这
我使用这个函数来发出 cURL 请求: function curl_request($options) //single custom cURL request. { $ch = curl_i
当我尝试归档某个项目时,Xcode 无法响应。如果让他一个人呆着,他会在很长一段时间后设法打开管理器。文件在那里。如果从 library/developer/xcode/archives 中手动删除,
有时我的 Eclipse 挂起,我需要猛烈地杀死它。但是,我一直无法正确地做到这一点。似乎 kill -9 实际上并没有以正确的方式关闭它,因为我仍然可以看到挂起的窗口。什么命令序列会正确杀死我的 E
我有一个JavaFX 8应用,它有时会挂起/冻结。我觉得我已经排除了造成此问题的许多原因,但它仍在发生。 不幸的是,我无法按需复制冻结/挂起。实际上,这仅发生在(到目前为止)我同事的计算机上。它可能在
我正在尝试学习网络基础知识,并且已经从this教程构建了回显服务器。我用telnet检查了服务器,它工作正常。 现在,当我使用Internet上的许多客户端示例中的一些示例时: // Create a
我正在尝试使用 SwiftUI 实现使用 Apple 登录,但在我输入正确的密码后它挂起。 我正在使用真实用户和模拟器以及 XCode 12.0 Beta。不幸的是,我现在没有可供测试的设备。我也尝试
我包括此简单的错误处理功能来格式化错误: date_default_timezone_set('America/New_York'); // Create the error handler. fun
我正在尝试为 VisualVM 安装一些插件,但它一直卡在下面的屏幕上 - 告诉我“请等待安装程序发现插件依赖项”。我运行的是 Ubuntu 12.04。当我尝试从“可用插件”列表中安装它们时,以及当
如果堆分配/取消分配/重新分配在另一个线程中进行,DbgHelp 库的 MiniDumpWriteDump() 将挂起。这是调用堆栈:DbgHelp 暂停其他线程,然后无限期地等待这些线程获得的互斥量
我正在尝试在 Eclipse C++ 版本中安装新软件。 帮助 -> 安装新软件。当我去安装新软件时,它会挂起或需要几个小时才能移动百分比。 我读到这是 JRE7 中的一个已知错误,我假设我在安装它后
这个问题已经有答案了: process.waitFor() never returns (12 个回答) 已关闭 3 年前。 我使用以下代码运行命令: open class AppRunner {
我正在尝试为 VisualVM 安装一些插件,但它一直卡在下面的屏幕上 - 告诉我“请等待安装程序发现插件依赖项”。我正在运行 Ubuntu 12.04。当我尝试从“可用插件”列表安装它们时,以及当我
如果堆分配/取消分配/重新分配在另一个线程中进行,DbgHelp 库的 MiniDumpWriteDump() 将挂起。这是调用堆栈:DbgHelp 暂停其他线程,然后无限期地等待这些线程获得的互斥量
尝试调试竞争条件,其中我们的应用程序的轮询器线程之一永远不会返回,导致 future 的轮询器永远不会被调度。用抽象术语来说,在捕获问题时隐藏我们的业务逻辑,这就是我们的代码路径。 我们必须更新远程服
我在程序完成时遇到 Java 的 ExecutorCompletionService 问题。 我需要使用 ExecutorCompletionService 而不是 ExecutorService 因
我是一名优秀的程序员,十分优秀!