我正在尝试创建通知,而不使用NotificationCompat.Builder. 如果不是真正需要(以及出于教育目的),动机不是使用支持库,我认为这是可能的,因为有“本机”Notification和NotificationManager向用户公开的类。
我的尝试如下:
Intent i = new Intent();
i.setClassName("com.test", "com.test.SomeActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
notification.setLatestEventInfo(this, title, content,pi);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0 , notification);
Run Code Online (Sandbox Code Playgroud)
这段代码只是运行,但没有出现通知,并且notificationManager.notify()通常返回void.
我最近在我的Ubuntu 14.04 LTS上安装了最新的稳定版Android Studio.SDK已正确配置.
我从空白的活动模板中创建了一个"活动"项目,并且没有对其进行任何更改.
在尝试构建或清理时,我偶尔会得到以下内容:
Failed to complete Gradle execution.
Cause:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
Run Code Online (Sandbox Code Playgroud)
这似乎是由VM的堆大小引起的.但添加XX:MaxPermSize=1024m只会使它出现次数更少,这意味着,有时我不会得到这个错误,而不会改变任何东西.所以要么它不是真正的解决方案,要么1024米是不够的(这似乎不对..)
但是,当我没有收到此错误时,构建仍然失败:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
/home/a/Android/Sdk/build-tools/19.1.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
/home/a/Android/Sdk/build-tools/19.1.0/aapt: …Run Code Online (Sandbox Code Playgroud)