Google kotlin 支持资料
来源:互联网 发布:写文章的软件 编辑:程序博客网 时间:2024/06/08 18:16
语法对比
kt code sample
fun getNotification1(title:String, body:String): Notification.Builder {
return Notification.Builder(applicationContext, PRIMARY_CHANNEL)
.setContentTitle(title)
.setContentText(body)
.setSmallIcon(smallIcon)
.setAutoCancel(true)
}
private val smallIcon:Int
get() = android.R.drawable.stat_notify_chat
private val manager: NotificationManager bylazy {
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
}
fun notify(id:Int, notification: Notification.Builder) {
manager.notify(id, notification.build())
}
java code sample
public Notification.Builder getNotification1(String title,String body) {
return newNotification.Builder(getApplicationContext(), PRIMARY_CHANNEL)
.setContentTitle(title)
.setContentText(body)
.setSmallIcon(getSmallIcon())
.setAutoCancel(true);
}
private int getSmallIcon() {
return android.R.drawable.stat_notify_chat;
}
private NotificationManager getManager() {
if (manager == null) {
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
return manager;
}
public void notify(int id,Notification.Builder notification) {
getManager().notify(id, notification.build());
}
https://github.com/googlesamples/android-NotificationChannels/blob/master/Application/src/main/java/com/example/android/notificationchannels/
as 3 下载 https://developer.android.google.cn/studio/archive.html
阅读全文
0 0
- Google kotlin 支持资料
- Kotlin资料
- kotlin学习资料分享
- Kotlin学习资料汇总
- Kotlin学习资料收集
- Kotlin 相关的资料
- Kotlin入门资料搜集
- Kotlin 学习资料
- Kotlin学习资料
- Kotlin学习资料整合
- Kotlin资料积累,Kotlin搞起来
- Kotlin:Google让我们使用Kotlin的理由
- kotlin项目推荐 资料汇总
- Kotlin 中文学习资料集锦
- Kotlin学习之资料整理
- Google为什么选择用Kotlin
- google adsense 相关资料
- Google App Engine 资料
- ACM HDU 1176 免费馅饼
- C#高效插入sql数据库数据
- Oracle查询语句简单回顾(一)
- STL list
- 【清单】 ---算法竞赛入门经典第二版 【例题+习题】【持续更新中..】
- Google kotlin 支持资料
- Kotlin: Java 6 废土中的一线希望
- 单元测试概述
- 简单理解struts1和struts2
- 异常及重写equals、toString方法
- C#高效插入sql数据库数据
- Spark性能优化:开发调优篇
- css之outline
- POJ_1990_MooFest_树状数组