- 浏览: 2551261 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Android Framework(I)Android Spring Json
1. Backgroud of Spring Android and Json
First, learn from spring.
Spring Mobile project that provides extensions to Spring MVC for developing mobile web apps.
Spring Android project that supports the development of native Android clients that communicate with spring-based back-ends.
Spring Mobile
1. A HandlerInterceptor that uses a DeviceResolver to detect the Device that originated the current HttpServletRequest.
2. The ability to inject the detected Device into @Controller methods and view templates to vary logic by device type.
Interceptor /WEB-INF/spring/appServlet/servlet-context.xml
<interceptors>
<beans:bean class="org.springframework.mobile.device.mvc.DeviceResolvingHandlerInterceptor" />
</interceptors>
JSP template:
Please try again<c:if test="${!currentDevice.mobile}"> or <a href="<c:url value="/signup" />">sign up</a></c:if>
Tiles-based page layout:
<definition name="page" templateExpression="/WEB-INF/layouts/${currentDevice.mobile ? 'mobile/' : 'standard/'}page.jsp"
Spring Android
The client side need to exchange data with the server over HTTPS via REST. We need to store username and password credentials on the
device itself, we opted for OAuth. RestTemplate for the REST API calls, and Spring Security for the OAuth client.
RestTemplate restTemplate = new RestTemplate(new CommonsClientHttpRequestFactory());
Event event = restTemplate.getForObject("https://myapp.com/event/{name}", Event.class, "springone2gx");
Greenhouse project URL
http://www.springsource.org/greenhouse
Run the green house locally
http://www.springsource.org/greenhouse/guide
Web APP
get the source codes
git clone https://github.com/SpringSource/greenhouse.git greenhouse
Greenhouse for Android
get the source codes
git clone https://github.com/SpringSource/greenhouse-android.git greenhouse-android
>vi pom.xml
add sdk path and platform to them
<sdk>
<path>/home/luohua/tools/android-sdk-linux_x86</path>
<platform>7</platform>
</sdk>
<emulator>
<avd>G7</avd>
</emulator>
Another example:
svn checkout http://geonames-android.googlecode.com/svn/trunk/ geonames-android-read-only
spring android samples:
git clone git://github.com/SpringSource/spring-android-samples.git spring-android-samples
spring android source:
git clone --recursive git://github.com/SpringSource/spring-android.git spring-android
2. Spring Android and Maven
Maven Configuration
Maven Android Plugin
Android applications are deployed to the device as an apk file, not a jar. You must specify this in the packageing configuration.
<packaging>apk</packaging>
<build>
...snip...
</build>
<repositories>
...snip...
</repositories>
Build Enviroment
>vi /etc/enviroment
ANDROID_HOME=/home/luohua/tools/android-sdk-linux_x86
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/luohua/tools/android-sdk-linux_x86/tools:
/home/luohua/tools/android-sdk-linux_x86/platform-tools"
Configure an Android Virtual Device
...snip...
Sample Application
>git clone git://git.springsource.org/spring-mobile/samples.git spring-mobile-samples
>cd spring-android-showcase
start the server side
>cd server
>mvn install
>cp /home/luohua/.m2/repository/org/springframework/android/spring-android-showcase-server
/1.0.0-BUILD-SNAPSHOT/spring-android-showcase-server-1.0.0-BUILD-SNAPSHOT.war
/home/luohua/tools/apache-tomcat-7.0.12/webapps/spring-android-showcase-server.war
>bin/startup.sh
verify the server side with this URL
http://localhost:8080/spring-android-showcase-server/
run the Android Client
modify the pom.xml <sdk><path><platform><emulator><avd>
>mvn clean install
>mvn android:emulator-start
problem here, the window of the emulator is too big
solution:
>telnet localhost 5554
>window scale 0.65
>quit
>mvn android:deploy
Problem: pkg: /data/local/tmp/spring-android-showcase-client.apkFailure [INSTALL_FAILED_OLDER_SDK]
That is only because of the version.
verify the AndroidManifest.xml
<uses-sdk android:minSdkVersion="4" />
modify the pom.xml:
<platform>10</platform>
<avd>10</avd>
I find an app named spring-android
>adb logcat
we can see the logs.
3. Spring Android and Eclipse IDE
Installing Plugins using the Eclipse Marketplace Client
Help ----> Eclipse Marketplace...
m2eclipse-android click 'Go' and 'Install'
egit click 'Go' and 'Install'
And in another way, we can install this manly
ADT
https://dl-ssl.google.com/android/eclipse
MAVEN2
http://m2eclipse.sonatype.org/sites/m2e
MAVEN2-ANDROID
https://svn.codespot.com/a/eclipselabs.org/m2eclipse-android-integration/updates/m2eclipse-android-integration/
Fetch the Sample Project
>git clone git://git.springsource.org/spring-mobile/samples.git spring-mobile-samples
create a Android Project in existing directory of spring-android-showcase/client
enable mavenmanagement
create a Dynamic Web Project in existing directory of spring-android-showcase/server
enable mavenmanagement
references:
http://www.makeurownrules.com/rest-spring-maven-android
http://code.google.com/p/geonames-android/
http://blog.springsource.com/2010/12/17/spring-android-and-maven-part-1/
http://www.springsource.org/spring-android
1. Backgroud of Spring Android and Json
First, learn from spring.
Spring Mobile project that provides extensions to Spring MVC for developing mobile web apps.
Spring Android project that supports the development of native Android clients that communicate with spring-based back-ends.
Spring Mobile
1. A HandlerInterceptor that uses a DeviceResolver to detect the Device that originated the current HttpServletRequest.
2. The ability to inject the detected Device into @Controller methods and view templates to vary logic by device type.
Interceptor /WEB-INF/spring/appServlet/servlet-context.xml
<interceptors>
<beans:bean class="org.springframework.mobile.device.mvc.DeviceResolvingHandlerInterceptor" />
</interceptors>
JSP template:
Please try again<c:if test="${!currentDevice.mobile}"> or <a href="<c:url value="/signup" />">sign up</a></c:if>
Tiles-based page layout:
<definition name="page" templateExpression="/WEB-INF/layouts/${currentDevice.mobile ? 'mobile/' : 'standard/'}page.jsp"
Spring Android
The client side need to exchange data with the server over HTTPS via REST. We need to store username and password credentials on the
device itself, we opted for OAuth. RestTemplate for the REST API calls, and Spring Security for the OAuth client.
RestTemplate restTemplate = new RestTemplate(new CommonsClientHttpRequestFactory());
Event event = restTemplate.getForObject("https://myapp.com/event/{name}", Event.class, "springone2gx");
Greenhouse project URL
http://www.springsource.org/greenhouse
Run the green house locally
http://www.springsource.org/greenhouse/guide
Web APP
get the source codes
git clone https://github.com/SpringSource/greenhouse.git greenhouse
Greenhouse for Android
get the source codes
git clone https://github.com/SpringSource/greenhouse-android.git greenhouse-android
>vi pom.xml
add sdk path and platform to them
<sdk>
<path>/home/luohua/tools/android-sdk-linux_x86</path>
<platform>7</platform>
</sdk>
<emulator>
<avd>G7</avd>
</emulator>
Another example:
svn checkout http://geonames-android.googlecode.com/svn/trunk/ geonames-android-read-only
spring android samples:
git clone git://github.com/SpringSource/spring-android-samples.git spring-android-samples
spring android source:
git clone --recursive git://github.com/SpringSource/spring-android.git spring-android
2. Spring Android and Maven
Maven Configuration
Maven Android Plugin
Android applications are deployed to the device as an apk file, not a jar. You must specify this in the packageing configuration.
<packaging>apk</packaging>
<build>
...snip...
</build>
<repositories>
...snip...
</repositories>
Build Enviroment
>vi /etc/enviroment
ANDROID_HOME=/home/luohua/tools/android-sdk-linux_x86
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/luohua/tools/android-sdk-linux_x86/tools:
/home/luohua/tools/android-sdk-linux_x86/platform-tools"
Configure an Android Virtual Device
...snip...
Sample Application
>git clone git://git.springsource.org/spring-mobile/samples.git spring-mobile-samples
>cd spring-android-showcase
start the server side
>cd server
>mvn install
>cp /home/luohua/.m2/repository/org/springframework/android/spring-android-showcase-server
/1.0.0-BUILD-SNAPSHOT/spring-android-showcase-server-1.0.0-BUILD-SNAPSHOT.war
/home/luohua/tools/apache-tomcat-7.0.12/webapps/spring-android-showcase-server.war
>bin/startup.sh
verify the server side with this URL
http://localhost:8080/spring-android-showcase-server/
run the Android Client
modify the pom.xml <sdk><path><platform><emulator><avd>
>mvn clean install
>mvn android:emulator-start
problem here, the window of the emulator is too big
solution:
>telnet localhost 5554
>window scale 0.65
>quit
>mvn android:deploy
Problem: pkg: /data/local/tmp/spring-android-showcase-client.apkFailure [INSTALL_FAILED_OLDER_SDK]
That is only because of the version.
verify the AndroidManifest.xml
<uses-sdk android:minSdkVersion="4" />
modify the pom.xml:
<platform>10</platform>
<avd>10</avd>
I find an app named spring-android
>adb logcat
we can see the logs.
3. Spring Android and Eclipse IDE
Installing Plugins using the Eclipse Marketplace Client
Help ----> Eclipse Marketplace...
m2eclipse-android click 'Go' and 'Install'
egit click 'Go' and 'Install'
And in another way, we can install this manly
ADT
https://dl-ssl.google.com/android/eclipse
MAVEN2
http://m2eclipse.sonatype.org/sites/m2e
MAVEN2-ANDROID
https://svn.codespot.com/a/eclipselabs.org/m2eclipse-android-integration/updates/m2eclipse-android-integration/
Fetch the Sample Project
>git clone git://git.springsource.org/spring-mobile/samples.git spring-mobile-samples
create a Android Project in existing directory of spring-android-showcase/client
enable mavenmanagement
create a Dynamic Web Project in existing directory of spring-android-showcase/server
enable mavenmanagement
references:
http://www.makeurownrules.com/rest-spring-maven-android
http://code.google.com/p/geonames-android/
http://blog.springsource.com/2010/12/17/spring-android-and-maven-part-1/
http://www.springsource.org/spring-android
发表评论
-
ionic UI(4)ionic2 framework - basic and components and native
2016-03-24 02:33 1261ionic UI(4)ionic2 framework - b ... -
ionic UI(3)TypeScript - handbook
2016-03-22 23:21 634ionic UI(3)TypeScript - handboo ... -
ionic UI(2)ionic2 framework - TypeScript - tutorial
2016-03-22 06:52 1656ionic UI(2)ionic2 framework - T ... -
Parse and Heroku Service(3)Parse Server and Parse Dashboard
2016-03-22 06:30 967Parse and Heroku Service(3)Pars ... -
Parse and Heroku Service(2)Mail Templates and Push Notification
2016-03-22 02:45 583Parse and Heroku Service(2)Mail ... -
ionic UI(1)Introduction
2016-03-19 03:18 723ionic UI(1)Introduction 1 Inst ... -
Parse and Heroku Service(1)Heroku Installation and Play
2016-03-19 00:13 824Parse and Heroic Service(1)Hero ... -
Hybrid(5)Customize Meteor Directly Google Login
2015-09-01 02:33 910Hybrid(5)Customize Meteor Direc ... -
Hybrid(4)Favorite Places - Google Login
2015-09-01 02:02 1341Hybrid(4)Favorite Places - Goog ... -
Hybrid(3)More Meteor Example - Social
2015-08-11 05:04 756Hybrid(3)More Meteor Example - ... -
Hybrid(2)meteor Running Android and iOS
2015-07-28 23:59 1049Hybrid(2)meteor Running Android ... -
Create the Google Play Account
2015-07-18 06:42 1101Create the Google Play Account ... -
Secure REST API and Mobile(1)Document Read and Understand OAUTH2
2015-07-14 00:36 764Secure REST API and Mobile(1)Do ... -
Screen Size and Web Design
2015-07-11 01:11 725Screen Size and Web Design iPh ... -
Hybrid(1)ionic Cordova meteor
2015-06-25 05:49 471Hybrid(1)ionic Cordova meteor ... -
Android Fire Project(1)Recall Env and Knowledge
2015-02-11 12:28 686Android Fire Project(1)Recall ... -
Android Content Framework(1)Concept
2014-06-14 13:54 1081Android Content Framework(1)Con ... -
Feel Android Studio(1)Install and Update Android Studio
2014-04-11 03:12 2029Feel Android Studio(1)Install a ... -
IOS7 App Development Essentials(2)iBeacon
2014-03-05 05:55 890IOS7 App Development Essentials ... -
IOS7 App Development Essentials(1) Persistent Store
2014-03-05 05:54 1327IOS7 App Development Essentials ...
相关推荐
在Android开发中,JSON(JavaScript Object Notation)是一种常见的数据交换格式,被广泛应用于服务器与客户端之间的通信。本文将深入探讨如何在Android中利用JSON进行网络数据交换,包括服务端和客户端的实现。 ...
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE' } ``` 2. 创建REST Template实例:在需要使用的地方初始化REST Template对象。 ```java RestTemplate restTemplate = ...
Spring Android是中国著名的开源框架Spring Framework在移动开发领域的延伸,它为Android开发者提供了Spring框架的核心功能,使得在Android平台上实现服务端常见的MVC架构、依赖注入、AOP(面向切面编程)等特性成为...
在本教程中,我们将深入探讨如何使用Spring MVC框架构建一个返回JSON格式数据的服务器。首先,这个项目涉及的技术栈包括Spring MVC、JDBC、JSON以及Gson。Spring MVC是Spring框架的一部分,它允许我们构建RESTful ...
Spring for Android 是著名的企业级开发框架Spring Framework的扩展,专为Android平台设计,旨在提供一套完整的、一致的开发工具集,使得Android开发者可以利用Spring的强大功能进行移动应用开发。本篇文章将深入...
在这个过程中,我们将学习如何使用 Spring MVC 来创建一个返回 JSON 格式数据的服务器,以及如何在 Android 应用中消费这些数据。 ### 第一部分:环境准备 1. **Eclipse Neon**:这是一个集成开发环境,用于编写 ...
本教程将深入探讨如何在Android应用中使用JSON进行网络数据交换,包括服务端和客户端的实现。 首先,我们需要理解JSON的基本结构。JSON是一种基于文本的数据格式,支持对象、数组、字符串、数值、布尔值和null等...
在安卓(Android)开发中,JSON(JavaScript Object Notation)是一种常见的数据交换格式,用于服务端与客户端之间的数据传输。本教程将详细讲解如何在Android应用中使用JSON进行网络数据交换,包括服务端和客户端的...
3. **移动应用开发**:Spring for Android让开发者能够利用Spring的特性开发Android应用,提升开发效率。 4. **云计算**:Spring Cloud Data Flow和Spring Cloud Stream提供了构建云原生应用的能力,便于在各种云...
在Android应用开发中,JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,广泛用于在网络客户端和服务端之间传输数据。本教程将详细介绍如何在Android应用中使用JSON进行网络数据交换,包括服务端和...
【Android-dianping-ba-framework基于Java的web项目框架】是一个专门为Android开发者设计的Web项目框架,它结合了Java技术栈,旨在简化Android应用后台服务的构建过程,提高开发效率和代码质量。在这个框架中,我们...
在Android开发中,JSON(JavaScript Object Notation)是一种常用的数据交换格式,因其轻量级、易读易写的特点,常用于客户端与服务器之间的数据交互。本教程将详细讲解如何在Android应用中实现对JSON数据的访问,...
│ Maven__org_springframework_boot_spring_boot_starter_json_2_2_6_RELEASE.xml │ Maven__org_springframework_boot_spring_boot_starter_logging_2_2_6_RELEASE.xml │ Maven__org_springframework_boot_...
这通常涉及到后端语言如Java(Spring Boot、Play Framework等)、Python(Django、Flask等)、Node.js(Express.js等)的使用,以及数据库操作(如MySQL、MongoDB、SQLite等)。 在开发过程中,安全问题不容忽视,...
2. 客户端:在客户端,如Android或iOS应用,可以使用网络库(如OkHttp、AFNetworking)发起HTTP请求,然后使用Gson或Fastjson解析响应的JSON数据。 四、JSON解析常见问题 1. 数据安全:由于JSON数据是明文传输,...
- **服务器端**:业务逻辑通过Spring的Beans注入到Servlet中,处理来自客户端的数据请求,并通过`doGet()`或`doPost()`方法响应客户端。 - **客户端(Android)**: 1. 创建`HttpPOST`或`HttpGet`请求对象,指定...
作为一款广泛应用于大数据处理、Web服务以及Android开发的工具,Fastjson在1.2.70版本中继续提供了高效且稳定的性能,本文将围绕其最新版Fastjson 1.2.70进行详细介绍。 一、Fastjson核心特性 1. **快速解析与生成...
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context=...
prototypal_aop_engine_android 如果您正在阅读此文件,也许您正在搜索有关此存储库中包含的代码的信息:该代码代表原型、有趣的* AOP 引擎的核心,该引擎实现的机制类似于 SpringFramework 实现的方法代理机制;...