pendingItent和 Ient
来源:互联网 发布:js 上传图片控件流处理 编辑:程序博客网 时间:2024/05/16 08:03
Java代码
1. Notification n = new Notification(R.drawable.face_1, "Service启动", System.currentTimeMillis());
2. PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, TServiceHolder.class), 0);
3. n.setLatestEventInfo(this, "任务标题", "任务内容", contentIntent);
4. nManager.notify(NOTIFICATION_ID, n); // 任务栏启动
PendingIntent和Intent的区别:An Intent issomething that is used right now; a PendingIntent is something that may create anIntent in the future. You will use a PendingIntent with Notifications,AlarmManager, etc.
1. GSM网络中android发送短信示例
(1)代码节选
Java代码
1. String msg ="你好,美女";
2. String number = "135****6784";
3. SmsManager sms = SmsManager.getDefault();
4.
5. PendingIntent pi = PendingIntent.getBroadcast(SmsActivity.this,0,new Intent(...),0);
6. sms.sendTextMessage(number, null, msg, pi, null);
7. Toast.makeText(SmsActivity.this,"发送成功",Toast.LENGHT_LONG).show();
(2)代码解释
PendingIntent就是一个Intent的描述,我们可以把这个描述交给别的程序,别的程序根据这个描述在后面的别的时间做你安排做的事情 (By giving a PendingIntent to anotherapplication, you are granting it the right to perform the operation you havespecified as if the other application was yourself,就相当于PendingIntent代表了Intent)。本例中别的程序就是发送短信的程序,短信发送成功后要把intent广播出去 。
函数SmsManager.sendTextMessage(StringdestinationAddress, String scAddress, String text, PendingIntent sentIntent,PendingIntent deliveryIntent)中参数解释:
1)PendingIntent sentIntent:当短信发出时,成功的话sendIntent会把其内部的描述的intent广播出去,否则产生错误代码并通过android.app.PendingIntent.OnFinished进行回调,这个参数最好不为空,否则会存在资源浪费的潜在问题;
2)PendingIntent deliveryIntent:是当消息已经传递给收信人后所进行的PendingIntent广播。
查看PendingIntent 类可以看到许多的Send函数,就是PendingIntent在进行被赋予的相关的操作。
- pendingItent和 Ient
- PendingItent
- pendingItent说明
- 关于pendingitent
- (4.3.2.18)PendingItent的第二次会覆盖第一次的intent内容
- . 和 ->
- || 和&&
- .和::
- “?”和“!”
- #和##
- && 和 ||
- 、和
- #和##
- .//和..//
- 和
- ?和\?
- ./ 和 ../
- #和##
- openfire重新配置
- openfre数据库
- 什么是Google Summer of Code
- LM2596-12 输出不恒定的问题
- templateEngine2 asp.net 开源模板引擎
- pendingItent和 Ient
- jsp中404错误的拦截
- javascript 实用技巧集锦
- Android中Context简介
- javase-Study03-04(陈曙光)
- NGINX常用负载均衡设置
- 动态广告布局
- 如何成为一个优秀的JSP程序员
- admob广告布局