首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

Android GIS开发系列-- 入门季(8) Json与Geometry的相互转换

在Android中json数据十分普遍,也很实用,在Arcgis中也同样支持Json数据,Json与Geometry可以相互转换,达到我们想要的数据。 一、Geometry转换成Json数据 这个实现十分简单,比如我们将一个点转换为Json,这时也同样用到GeometryEngine这个强大的类。 Point point = new Point(113, 23); String json = GeometryEngine.geometryToJson(SpatialReference.create(SpatialReference.WKID_WGS84), point); Log.w("TAG", "json===" + json); 打印Log的结果为json==={"x":113.0,"y":23.0,"spatialReference":{"wkid":4326}},是不是很简单。 二、Json转换为Geometry 同样用到GeometryEngine类中的jsonToGeometry方法,我们将上面的json再转换回去。 try { String jsonStr = "{\"x\":113.0,\"y\":23.0,\"spatialReference\":{\"wkid\":4326}}"; JsonFactory jsonFactory = new JsonFactory(); JsonParser jsonParser = jsonFactory.createJsonParser(jsonStr); MapGeometry mapGeometry = GeometryEngine.jsonToGeometry(jsonParser); Point mPoint = (Point) mapGeometry.getGeometry(); Log.i("TAG","mPoint---"+mPoint.getX()+"==="+mPoint.getY()); } catch (IOException e) { e.printStackTrace(); } 代码执行结果mPoint---113.0===23.0。注:jsonFactory.createJsonParser这个方法可带入的参数也是比较多的,比如:file、outputStream、byte数组等等,有兴趣的小伙伴可以研究研究。 没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。 本文转自wenglabs博客园博客,原文链接http://www.cnblogs.com/arxive/p/7751932.html :,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发 AIDL使用自定义对象作参数或返回值

http://www.pocketdigi.com/20121129/952.html 默认,AIDL支持对象作参数,但需要该对象实现Parcelable接口,且aidl文件应该是该类在同一包下,需要单独给该类定义一个aidl文件. 定义模型类: EnglishItem.java: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 package com.pocketdigi.english.aidl; import android.os.Parcel; import android.os.Parcelable; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; import com.pocketdigi.english.utils.Constants; import com.pocketdigi.english.utils.Des; @DatabaseTable(tableName = "listenlist") public class EnglishItem implements Parcelable { /** * */ private static final long serialVersionUID = -1756522544697525757L; @DatabaseField(id = true) private int id; @DatabaseField private String title; @DatabaseField private String category; @DatabaseField private String mp3url; @DatabaseField private String lrcurl; @DatabaseField private String txturl; public static final Parcelable.Creator<EnglishItem> CREATOR = new Parcelable.Creator<EnglishItem>() { public EnglishItem createFromParcel(Parcel in) { return new EnglishItem(in); } public EnglishItem[] newArray(int size) { return new EnglishItem[size]; } }; private EnglishItem(Parcel in) { readFromParcel(in); } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public String getMp3url() { return Des.decodeValue(Constants.DES_KEY, mp3url); } public void setMp3url(String mp3url) { this.mp3url = mp3url; } public String getLrcurl() { return Des.decodeValue(Constants.DES_KEY, lrcurl); } public void setLrcurl(String lrcurl) { this.lrcurl = lrcurl; } public String getTxturl() { return Des.decodeValue(Constants.DES_KEY, txturl); } public void setTxturl(String txturl) { this.txturl = txturl; } @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel out, int flag) { // TODO Auto-generated method stub out.writeInt(id); out.writeString(title); out.writeString(category); out.writeString(mp3url); out.writeString(lrcurl); out.writeString(txturl); } /** * 读 * @param in */ public void readFromParcel(Parcel in) { id=in.readInt(); title=in.readString(); category=in.readString(); category=in.readString(); lrcurl=in.readString(); txturl=in.readString(); } } Parcelable.Creator不可少。 同包下定义一个EnglishItem.aidl: 1 2 package com.pocketdigi.english.aidl; parcelable EnglishItem; 最后是调用接口aidl: PlayerAidl.aidl: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 package com.pocketdigi.english.aidl; import com.pocketdigi.english.aidl.EnglishItem; interface PlayerAidl { /** *传入列表 **/ void putList(inout List<EnglishItem> item); /** *播放指定音频 **/ void play(int index); void pause(); /** *暂停后恢复播放 **/ void resume(); /** *删除指定项 **/ void delete(int position); /** *停止服务 **/ void stopService(); } 分类: android solve 本文转自wanqi博客园博客,原文链接:http://www.cnblogs.com/wanqieddy/p/3922846.html如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册