- 浏览: 41393 次
- 性别:
- 来自: 济南
最新评论
-
kensunhu:
正是我想要的。典型的app ui布局。谢谢!
android UI - 仿威信tab样式 -
007007jing:
bing_zz 写道兄弟加油!谢谢
android2.3 api demo 学习系列(7)--App/Activity/Hello World -
bing_zz:
兄弟加油!
android2.3 api demo 学习系列(7)--App/Activity/Hello World
android2.3 api demo 学习系列(22)--App/Notification/Notifying Service Controller
- 博客分类:
- Android ApiDemo
因为还没有看到service的demo,这里先不对service做过多的介绍,本demo的主要意图是通过service发送notification
1、在service的onCreate方法中启动新的线程来发送notification
@Override public void onCreate() { mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. Thread notifyingThread = new Thread(null, mTask, "NotifyingService"); mCondition = new ConditionVariable(false); notifyingThread.start(); }
2、具体执行
private Runnable mTask = new Runnable() { public void run() { for (int i = 0; i < 4; ++i) { showNotification(R.drawable.list, R.string.app_notification_service_happy); if (mCondition.block(5 * 1000)) break; showNotification(R.drawable.launcher, R.string.app_notification_service_sad); if (mCondition.block(5 * 1000)) break; } // Done with our work... stop the service! NotifyingService.this.stopSelf(); } };
3、notification的实例化和发送
private void showNotification(int moodId, int textId) { // In this sample, we'll use the same text for the ticker and the expanded notification CharSequence text = getText(textId); // Set the icon, scrolling text and timestamp. // Note that in this example, we pass null for tickerText. We update the icon enough that // it is distracting to show the ticker text every time it changes. We strongly suggest // that you do this as well. (Think of of the "New hardware found" or "Network connection // changed" messages that always pop up) Notification notification = new Notification(moodId, getText(R.string.app_notification_service_title), System.currentTimeMillis()); // The PendingIntent to launch our activity if the user selects this notification PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, NotifyingController.class), 0); // Set the info for the views that show in the notification panel. notification.setLatestEventInfo(this, getText(R.string.app_notification_service_title), text, contentIntent); // Send the notification. // We use a layout id because it is a unique number. We use it later to cancel. mNM.notify(MOOD_NOTIFICATIONS, notification); }
里面涉及到的notification的内容基本在上一篇文章都有详细的介绍:android2.3 api demo 学习系列(21)--App/Notification/Incoming Message
效果图:
发表评论
-
android2.3 api demo 学习系列(23)--App/Notification/StatusBarNotification
2012-07-07 19:51 1303apidemo-StatusBarNotification里面 ... -
android2.3 api demo 学习系列(21)--App/Notification/Incoming Message
2012-07-06 11:55 2436现在我们开始学习android的Status Bar Noti ... -
android2.3 api demo 学习系列(20)--App/Menu
2012-07-06 09:58 1116现在来学习下menu的相关 ... -
android2.3 api demo 学习系列(19)--App/Intent and Launcher Shortcuts
2012-07-06 09:36 1067第一个demo:Intent,根据指定的类型,枚举出所有符合条 ... -
android2.3 api demo 学习系列(18)--App/Dialog
2012-07-06 09:13 961今天主要学习Dialog: 1、一般的dialog ... -
android2.3 api demo 学习系列(17)--App/Alarm/AlarmController and Alarm Service
2012-07-03 17:12 2146本次学习将apidemo中得两个demo:AlarmContr ... -
android2.3 api demo 学习系列(16)--App/Activity/Translucent and Blur activity
2012-07-03 11:47 1863本次同样是将apidemo中得两个demo合并起来学习:Tra ... -
android2.3 api demo 学习系列(15)--App/Activity/SetWallpaper
2012-07-03 11:00 1095本次示例我们整合了apidemo里面的两个demo:SetWa ... -
android2.3 api demo 学习系列(14)--App/Activity/Screen Orientation
2012-07-03 09:50 3085下面我们来学习下Screen Orientaiton的demo ... -
android2.3 api demo 学习系列(13)--App/Activity/Save & Restore
2012-07-02 17:29 1439前面文章android2.3 api demo 学习系 ... -
android2.3 api demo 学习系列(12)--App/Activity/Reorder Activitys
2012-07-02 16:45 964Reorder Activitys Demo主要是实现打开ac ... -
android2.3 api demo 学习系列(11)--App/Activity/Redirection
2012-07-02 15:52 834APIDEMO里面的redirection示例本身并没有新技术 ... -
android2.3 api demo 学习系列(10)--App/Activity/RecevieResult
2012-07-02 14:48 961在先前的文章 activity之间跳转传值 已经学习过这方面的 ... -
android2.3 api demo 学习系列(9)--App/Activity/QuickContactsDemo
2012-07-01 19:46 963现在我们来学习如何使用Content Provider来访问a ... -
android2.3 api demo 学习系列(8)--App/Activity/Preference State
2012-07-01 19:45 874android保存数据有很多种方式,其中最简单的就是使用Sha ... -
android2.3 api demo 学习系列(7)--App/Activity/Hello World
2012-06-29 14:03 1052学习android当然不能少了HelloWorld,接下来我们 ... -
android2.3 api demo 学习系列(6)--App/Activity/ForwardActivity
2012-06-29 13:50 807本次学习activity的跳转 1、构建intent ... -
android2.3 api demo 学习系列(5)--App/Activity/Dialog
2012-06-29 11:42 977前面我们已经学习了Custom Dialog 和 Custom ... -
android2.3 api demo 学习系列(4)--App/Activity/Custom Title
2012-06-29 11:26 1059android的标题栏默认是由android:lable定义的 ... -
android基础知识---Providing Resources
2012-06-29 10:42 776android的可使用的资源文件,google建议我们在开发应 ...
相关推荐
react-native-in-app-notification-master.rar
npm install --save react-native-push-notification react-native link NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications...
Android Upload Service Easily upload files in the background with automatic Android Notification Center progress indication. Download the latest demo app APK which uses the library and try it ...
react-native-in-app-notification的基本外观: 您可以使用自定义组件来使react-native-in-app-notification : 安装 yarn add react-native-in-app-notification 要么 npm install react-native-in-app-...
Laravel开发-laravel-mobile-notification 向移动设备(APN、GCM)发送推送通知的Laravel/Lumen包
Android-react-native-push-notification.zip,响应本机本地和远程通知,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
"在窗口顶端或者下端弹出自定义的提示视图(notification View)。例如,图中上方的黑色标签“This is the notification.""。可用于显示当前app的状态,用户操作的提示等等。" 注意:请在Mac下解压使用
在窗口顶端弹出自定义的提示视图(notification View)。弹出的notification view可以自动隐藏。如果有多个notification view,则进行排队,按顺序显示。可用于显示当前app的状态,用户操作的提示、提醒通知等等。...
该存储库包含荷兰语COVID-19 Notification App CoronaMelder的原生Android实现。 android应用位于您当前正在查看的存储库中。 可以在以下位置找到iOS应用: : 后端可以在这里找到: : 可以在此处找到用作开发应用...
Laravel开发-laravel-push-notification Push Notification 服务端支持 app的推送通知发送工具,支持结果的apns和安装的gcm
自定义UITabBar。自定义Tab Bar的文字、颜色和图片,不同tab之间切换的动作效果,以及自定义Tab Bar弹出消息的样式。 注意:请在Mac下解压使用
极光推送 JAVA服务端 jpush-client-3.2.8 与 集成源码 jpush-api-java-client-master
Android上的另一种推送通知解决方案是 ,其功能是在iOS和Android上提供相同的API,而该功能在Android上支持更多的通知功能。React本机系统通知 发送或安排React Native的Android系统通知。目录import React , { ...
yarn add vue-toast-notification # npm npm install vue-toast-notification 用法 import Vue from 'vue' ; import VueToast from 'vue-toast-notification' ; // Import one of the available themes //import '...
Android 通知(notification)简单实用Demo,包含点击功能简单例子,供大家下载学习
learn push notification with android
android notification完全解析Demo
主要利用了notification service 和receiver 实现了用户通知栏更新,失败了点击重新下载,下载好了点击自动安装,布局很丑,请根据自己项目的实际需求自行修改
运行API: java -jar target/notification-service-0.0.1-SNAPSHOT.jar server config.yml API文档 获取最新通知 从“以来”获取请求用户的最新通知。 如果未指定“since”,则返回过去 24 小时内的最新通知。 项目...
安装使用yarn或npm将软件包安装为项目依赖项: $ yarn add @dafcoe/vue-notification--- or ---$ npm install --save @dafcoe/vue-notification用法全局(在main.js / main.ts文件上)或本地(在组件上)导入...