Android O新增的一个特性,系统会在通知栏显示当前在后台运行的应用,其实际是显示启动了前台服务的应用,并且当前应用的Activity不在前台.具体我们看下源码是怎么实现的. 1 APP调用startService或startForegroundService启动一个service. startService和startForegroundService在Android O上主要有两个区别: 一个是后台应用无法通过startService启动一个服务,而无论前台应用还是后台应用,都可以通过s…
Android Studio方便好用,但是Android Studio Gradle Build Running很慢 解决方法: C:\Users\你的用户名\.gradle 目录下新建一个文件名为 gradle.properties 的文件 文件的内容为: org.gradle.daemon=true…
IOS的沉浸式通知栏很高大上,通知栏和app统一颜色或样式,很美观.android上面也早就人实现这种效果了. 我在这边也写一个实现通知栏沉浸式的方法,目前只实现了相同颜色. 先要改布局文件xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" andro…
非常久没有使用Android的通知功能了,今天把两年前的代码搬出来一看.发现非常多方法都废弃了,代码中各种删除线看的十分不爽.于是乎,打开Google,查看官方文档.学习最新的发送通知栏消息的方法. 本文中的代码均參照谷歌官方文档编写: http://developer.android.com/guide/topics/ui/notifiers/notifications.html 1.首先.获取系统的通知服务: NotificationManager nm = (NotificationMan…
package com.example.mvp; import cn.ljuns.temperature.view.TemperatureView;import presenter.ILoginPresenter;import presenter.LoginPresenterCompl;import android.os.Bundle;import android.app.Activity;import android.app.Notification;import android.app.No…
本文的本本win7 64bit 6G android studio2.1 在运行程序的时候Gradle Build Running 特别慢,一个helloworld都快2min了 1.开启gradle单独的守护进程 在下面的目录下面创建gradle.properties文件: /home/<username>/.gradle/ (Linux) /Users/<username>/.gradle/ (Mac) C:\Users\<username>\.gradle (Wi…
编译android时,遇到报错:Errors occurred during the build.Errors running builder 'Android Pre Compiler' on project 'XXX' java.lang.NullPointerException 错误原因:工程目录下有很多.svn目录 解决方法: Open properties of project in Eclipse then Resources -> Resource filters. Click t…
app发送通知消息到通知栏中的关键代码和点击事件: package com.example.notifications; import android.os.Bundle; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Cont…
1.AndroidManifest.xml注意要同时注册Notification02Activity <!-- 状态通知栏 Notification -->        <activity            android:name="com.example.notification.Notification01Activity"            android:label="状态通知" >            <inte…
遇到的最大的问题是监听不到用户清除通知栏的广播.所以是不能监听到的. 自定义通知栏的View,然后service运行时更改notification的信息. /** * Show a notification while this service is running. * 在service运行时,显示通知信息 */ public void showNotification() { NotificationManager mNM = (NotificationManager)getSystemSe…