Ir al contenido principal

Android: Conectar a un servidor via RESTful - Spring Android


Android: Conectar a un servidor via RESTful

llamar a un REST web service desde Android usando Spring Android


 Introduccion:
La  aplicacion acontinuacion, llamara a un servicio publicado por Google, el cual  recibe un texto  el cual sera buscado , y retornara  4 resultados.  En este  ejemplo se  buscara  " Android-Peru.com"
 
  • Requisitos
    • Librerias
spring-android-rest-template-1.0.0.M2.jar
jackson-mapper-asl-1.7.2.jar
jackson-core-asl-1.7.2.jar
commons-httpclient-3.1.jar
 
    • SDK
           SDK Platform Android 2.3.3 API 10, revision 1
 
  • Creacion del Proyecto:
Project Name: Android01
Application Name: Android01
Package Name: com.androidperu.android01
Create Activity:  checked
Min SDK Version: 1

  • Abrir el archivo AndroidManifest.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
xml version="1.0" encoding="utf-8"?>
<manifest android:versioncode="1" android:versionname="1.0" package="com.androidperu.android01" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minsdkversion="8">
<uses-permission android:name="android.permission.INTERNET">uses-permission>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:label="@string/app_name" android:name=".Android01">
            <intent-filter>
                <action android:name="android.intent.action.MAIN">
                <category android:name="android.intent.category.LAUNCHER">
            category>action>intent-filter>
        activity>
 
    application>
uses-sdk>manifest>
  • Abrir el archivo main.xml

1
2
3
4
xml version="1.0" encoding="utf-8"?>
<linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<textview android:id="@+id/resultText" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="@string/hello">
textview>linearlayout>

Comentarios

Entradas populares de este blog

Java POI HSSFCell : añadir comentario en una celda

POI HSSFComment: Una manera simple de añadir un comentario en una celda de excel usando el metodo cell.setCellComment(). public class ExcelTools { public static void main(String[] args){ //escribirExcel(); //leerExcel(); validarValoresDuplicadosLista(); System.out.println("Ejemplo Finalizado."); } public static void escribirExcel(){ try{ //Se crea el libro Excel HSSFWorkbook wb = new HSSFWorkbook(); //Se crea una nueva hoja dentro del libro HSSFSheet sheet = wb.createSheet("HojaEjemplo"); //Se crea una fila dentro de la hoja HSSFRow row = sheet.createRow((short)0); HSSFPatriarch patr = sheet.createDrawingPatriarch(); //Creamos celdas de varios tipos row.createCell((short)0).setCellValue(1); row.createCell((short)1).setCellValue(1.2); row.createCell((short)2).setCellValue("ejemplo&

Debugging Remoto con Eclipse + WebSphere 7 + Maven

Tienes proyectos java en Maven y no puedes ubicar bugs fácilmente a falta de junit. Sin embargo, existe la alternativa de debugear la aplicación web a través de Java Debugger (jdb). Aquí les muestro una guía de como hacer un debug remoto de la aplicación web en Eclipse y WebSphere 7 a través de Java Debugger (JDB). Eclipse <----> Java Debugger (jdb) <----> WebSphere 7 1. Habilitar el WebSphere en modo Debug. Para esto seguir los siguientes pasos:  1. Servers –> Server Types –> WebSphere application servers 2. Under Server Infrastructure section –> expandir Java and Process Management –> Process definition 3. dentro de la seccion Additional Properties –> click Java Virtual Machine 4. clic en el check “Debug Mode” 5. En texbox Debug arguments, poner este valor:  -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 6. Reiniciar el servidor WebSphere. Ahora, WebSphere se inicia en modo debug, y escuchando en el pu

DB2 Error SQL20054N

Ejecutando un alter table me da el  siguiente error: db2 "ALTER TABLE PRG_REC.ESTIMADO_OBJETIVO DROP COLUMN VTA_OBJ_CAMP_FALTA_EXTRANJERA"; Error:  [db2inst1@ibmdb2test]:/home/db2inst1/1223/REQ1223/rollback$ db2 "ALTER TABLE PRG_REC.ESTIMADO_OBJETIVO DROP COLUMN VTA_OBJ_CAMP_FALTA_EXTRANJERA"; DB21034E  The command was processed as an SQL statement because it was not a valid Command Line Processor command.  During SQL processing it returned: SQL20054N  The table "PRG_REC.ESTIMADO_OBJETIVO" is in an invalid state for the operation.  Reason code="23" .  SQLSTATE=55019 Segun IBM la descripcion del error: SQL20054N:  La tabla   nombre-tabla   está en un estado no válido para la operación. Código de razón= código-razón . 23 Se ha realizado el número máximo de modificaciones recomendadas de REORG. Se permite un máximo de tres modificaciones recomendadas de REORG en una tabla antes de que se deba realizar reorg, para actualizar las fila