针对Android应用中Gallery内存溢出的解决方案
详细信息    本馆镜像全文|  推荐本文 |  |   获取CNKI官网全文
摘要
随着移动设备的迅猛发展,越来越多的开发人员选择向移动平台进军。在近两年中,Android的发展十分强势,已成功超越塞班和IOS成为市场占有率的第一名,越来越多的Android应用也如雨后春笋般出现。
     本文所描述的是一个在Android平台上浏览体育赛事新闻的应用。根据其特点及应用实现过程中出现的问题,提出了一种针对在Android应用中因浏览Gallery(画廊)时下载大量图片而导致应用内存溢出的解决方案。
     在Android应用中,用户往往需要浏览大量的图片,而Gallery提供了一个很好的机制,用户可以通过左右移动来浏览图片。如果将Gallery中所需的大容量图片都从网站上下载到内存,则有很大概率会导致应用OOM(Out Of Memory:内存溢出);而如果将图片都下载到外存(SD卡)中,却因Android旗下的手机设备参差不齐,极有可能没有任何外存设备而不可行。
     本文针对此背景,研究了一套可用于解决在Gallery浏览时内存溢出的解决方案:通过任务调度、缓存设立以及线程的控制,做到了既能够使之适应Android旗下各类产品,又基本避免了OOM的可能性,并通过大量的应用实验证明了其可靠性与稳定性。
     解决方案现已成功在应用上付诸实践,并且在安卓市场上成功上线。根据用户反馈,应用中Gallery浏览功能性能稳定,完全避免了OOM的发生,其优质的体验效果得到了用户的一致好评。
With the rapid development of mobile devices, many developers choose the mobile platform as their new direction. In the recent two years, the development of Android is very fast, it becomes NO.1 after catching up Symbian and ios, and more and more Android apps appear.
     The paper is about an app of browsing sports news base on Android. According to its features and problems in developing, we propose a solution on OOM of downloading numerous images when a Android user browses the Gallery.
     In Android applications, users often browse a great quantity of images, and Gallery provides a well performed mechanism; users may browse the images by swaying. If we download all the images from Internet and send them into memory, the application may crash because of OOM(OUT OF MEMORY); And if we download the images to the SD card, it's also infeasible because many cell phones may not have SD card.
     Aim at that background; we propose a solution to solve this problem. We make it possible to apply to any product of Android and avoid OOM by task scheduling, caching and thread control, and guarantee the stability of such solution through experiments.
     The solution has been fulfilled on the app, and we can download the app on the Android market right now. According to the feedback from users, it's stable on Gallery browsing and it can totally avoid OOM, and The experience of high quality is highly appreciated by users.
引文
[1]Ed Burnette. Hello, Android:Introducing Google's Mobile Development Platform. Pragmatic Bookshelf, November,2009.
    [2]邸烁.Android揭秘和未来发展趋势[EB/OL].http://publish.itpub.net/zt/ Android/index.html,2008-03-17.
    [3]Cay S.Horstmann, Gary Cornell. Java2核心编程.第六版.清华大学出版社,2003年9月.
    [4]盖索林.Google Android开发入门指南.第二版.人民邮电出版社,2009年02月13日.
    [5]张仕成.基于Google Android平台的应用程序开发与研究[J].电脑知识与技术,2009,5(28):7959-7962.
    [6]Shane Condor, Lauren Decry. Android移动应用开发从入门到精通[M].北京:人民邮电出版社,2010.
    [7]Reto Meier. Android高级编程[M].北京:清华大学出版社,2010.
    [8]公磊,周聪.基于Android的移动终端应用程序开发与研究[J].计算机与现代化,2008(8):86-89.
    [9]张利国,代闻,龚海平.Android移动开发案例详解[M].北京:人民邮电出版社,2010.
    [10]差沙.用Android开发手机应用[J].程序员,2008(1):25-27.
    [11]廖永刚,余冬梅,张秋余.架构与安全机制的研究[J].计算机工程与设计,2006,27(4):575-577.
    [12]马越.Android的构架与应用.中国地质大学(北京),2008年.
    [13]姚昱曼,刘卫国.Android的架构与应用开发研究[J].计算机系统应用,2008(11):110-112.
    [14]余志龙,陈昱勋,郑名杰,陈小凤,郭秩均.Google Android SDK开发范例大全.人民邮电出版社,2009年7月.
    [15]叶达峰.Eclipse编程技术与实例[M].北京:人民邮电出版社,2006.
    [16]杨丰盛.Android技术内幕·系统卷.机械工业出版社,2011年5月.
    [17]杨丰盛.Android应用开发揭秘[M].北京:机械工业出版社,2010.
    [18]Doug Lea. Concurrent programming in Java.2nd edition. Addison-Wesley Professional,05 November,1999.
    [19]刘向辉.基于Java的移动终端中间件的研究与设计[D].上海:华东师范大学,2005.
    [20]孔令波,唐世渭,杨冬青.XML数据的查询技术[J].软件学报,2007,18(6):1400-1418.
    [21]孔令波,唐世渭,杨冬青.XML数据索引技术[J].软件学报,2005,16(12):2063-2079.
    [22]龙泉,陆伟.基于XML的多媒体信息检索[J].情报杂志,2007(10):48-50,54.
    [23]陈海山著.深入Java Servlet网络编程.北京:清华大学出版社,2002.2.
    [24]Jean-Marie Bonnin, Carlo Giannelli, Thomas Magedanz. Developing and Benchmarking Native linux applications on Android:MobileWireless Middleware, Operating Systems, and Applications Second International Conference, Mobilware 2009, Berlin, Germany, April 28-29,2009 Proceedings.
    [25]A.-D. Schmidt, R. Bye, H.-G. Schmidt, J. Clausen, O. Kiraz, K. Yu ksel, A. Camtepe, and S. Albayrak. Static analysis of executables for collaborative malware detection on Android. In IEEE International Congress on Communication (ICC) 2009-Communication and Information Systems Security Symposium,2009.
    [26]A. Shabtai, Y. Fledel, and Y. Elovici. Securing Android-powered mobile devices using selinux. IEEE Security and Privacy,99(PrePrints),2009.
    [27]W. Enck, M. Ongtang, and P. McDaniel. Understanding Android security. IEEE Security and Privacy,7(1):50-57,2009.
    [28]Gartner Inc. "Android to overtake iPhone in 2012," October 2009, http://www.computerworld.com/s/article/9139026/Android-to-grab-No.-2-spot-by-2012-says-Gartner.
    [29]A. Shabtai, Y. Fledel, U. Kanonov, Y. Elovici, S. Dolev, C. Glezer, "Google Android:A Comprehensive Security Assessment," IEEE Security and Privacy. vol.8(2), March/April 2010, pp.35-44.
    [30]L. Batyuk, A.-D. Schmidt, H.-G. Schmidt, A. Camtepe, and S. Albayrak. Developing and benchmarking native linux applications on Android. In MobileWireless Middleware, Operating Systems, and Applications,2009.
    [31]H. Ishiguro, "Scientific Issues Concerning Androids," Int. J. Robotics Research, vol.26, no.1, pp.105-117,2007.
    [32]Anders Hartvoll Ruud, "Designing a Game Development Framework for Teaching Software Architecture on the Android Platform", Master thesis at NTNU, June 2009.
    [33]Gong Lei, Zhou Cong. Development and research of mobile terminal application based on Android (in Chinese)[J]. Computer and Modernization,2008.
    [34]Yu Zhilong, Chen Yuxun, Zheng Jie etc. Collection of Google Android SDK development paradigms (in Chinese) [M]. Posts & Telecom Press,2009.
    [35]Gao Huantang. Principles of Android application framework and 36 plans of program design (in Chinese) [M]. MISOO Design Center,2008.
    [36]Jin Yan, Yao Shanglang. Getting started and actual development of Google Android (in Chinese) [M]. Posts & Telecom Press,2009.
    [37]C. Haseman, Android Essentials, PDF Electronic Book,2008. Available from: http://Androidos.cc/dev/index.php.
    [38]N. Gramlich, Android Programming, PDF Electronic Book,2008. Available from: http://Androidos.cc/dev/index.php

© 2004-2018 中国地质图书馆版权所有 京ICP备05064691号 京公网安备11010802017129号

地址:北京市海淀区学院路29号 邮编:100083

电话:办公室:(+86 10)66554848;文献借阅、咨询服务、科技查新:66554700