设为首页 加入收藏

TOP

Android短彩信附件机制
2014-11-24 07:56:44 来源: 作者: 【 】 浏览:1
Tags:Android 彩信 附件 机制

ComposeMessageActivity.java
private void editSlideshow() {
// The user wants to edit the slideshow. That requires us to persist the slideshow to
// disk as a PDU in saveAsMms. This code below does that persisting in a background
// task. If the task takes longer than a half second, a progress dialog is displayed.
// Once the PDU persisting is done, another runnable on the UI thread get executed to start
// the SlideshowEditActivity.
getAsyncDialog().runAsync(new Runnable() {
@Override
public void run() {
// This runnable gets run in a background thread.
mTempMmsUri = mWorkingMessage.saveAsMms(false);
}
}, new Runnable() {
@Override
public void run() {
// Once the above background thread is complete, this runnable is run
// on the UI thread.
if (mTempMmsUri == null) {
return;
}
Intent intent = new Intent(ComposeMessageActivity.this,
SlideshowEditActivity.class);
intent.setData(mTempMmsUri);
startActivityForResult(intent, REQUEST_CODE_CREATE_SLIDESHOW);
}
}, R.string.building_slideshow_title);
}


这段代码比较简单,总的来说就是先构建一个Uri,用于表示附件的唯一Id,然后这个Uri被传到附件幻灯片编辑页面,也就是SlideshowEditActivity.java。重点就是在构建Uri的过程中,做了什么事情。(关于getAsyncDialog(),并不影响我们分析,读者可跳过。其实这段代码是异步执行的,也就是说代码在主线程中调用了一下,主线程就返回了,也就是常说的不阻塞主线程。这段代码归根结底是调用了AsycnTask,只不过Mms应用封装了它并对外提供了异步线程接口。如果第一个Runnable在0.5秒之后没有执行完毕,那么会弹出一个progressBar,提示信息就是第三个参数,如果执行完毕,就执行第二个Runnable)。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android动画案例,淡入淡出效果 下一篇动态内存分配(malloc/free)简单实..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·请问c语言刚入门,该 (2025-12-26 10:21:04)
·python 编程怎么定义 (2025-12-26 10:21:01)
·09-指 针 (一)-c语言 (2025-12-26 10:20:58)
·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)