Documente Academic
Documente Profesional
Documente Cultură
Servicios Web
15 de noviembre de 2015
ALUMNO :
SARAVIA TASAYCO JUAN EMILIO
PROFESOR :
JOSE MANUEL CASTILLO CARA
CURSO :
PROGRAMACION DE DISPOSITIVOS MOVILES
ndice
ndice
1
2
3
4
5
6
7
Actividad 1
Actividad 2
Actividad 3
Actividad 4
Actividad 5
Actividad 6
Practica
3
5
5
6
9
9
11
actividad 1
actividad 1
1. Entramos en www.hostinger.com.ar y creamos nuestra cuenta.
2. Una vez creada vamos a administrar y luego en el apartado
Base de datos pulsamos Base de datos MySQL. Le ponemos
un nombre de BBDD, usuario y contrasea.
a) Estos datos de usuario y BBDD se tendrn que poner en el
fichero db_config.php
3. Verificamos que est creada la BDD.
4. Abrimos el PHPMyAdmin del lado izquierdo.
a) Creamos la tabla empresa que puede verificarlo en el
fichero db_get_allempresas.
b) Creamos las columnas que pone el fichero siendo:
1) id clave primaria y haciendo check en la columna A_1
2) Cotejamiento de nombre ponemos ut8_spanish...
3) A nombre le ponemos una longitud.
5. Una vez creada aadimos 3 registros de prueba.
6. Ahora vamos a Administracion de archivos 2 de nuestro
panel y lo instalamos.
7. En Public_html creamos un directorio que se llame
laboratorio8.
a) En dicha carpeta introducimos los tres archivos. Tenga en
cuenta que puede que se hayan modificado segn los datos
de acceso y tabla que hayas creado.
b) Explique los ficheros PHP.
8. Para verificar nuestro servidor escribimos la url debiendo salir
todos los registros insertados previamente.
a) www.dominio.sub/laboratorio8/get_all_empresas.php
actividad 1
actividad 2
actividad 2
1. Ingresar los permisos de conexin
<usespermission android : name= " android . permission . INTERNET" />
actividad 3
1. Creamos una nueva clase JAVA y le llamamos JSONParser.
2. Creamos los atributos y el constructor.
static
static
static
public
}
InputStream i s = n u l l ;
JSONObject j O b j = n u l l ;
String json = " " ;
JSONParser ( ) {
actividad 4
} c a t c h ( UnsupportedEncodingException e ) {
e . printStackTrace ( ) ;
} catch ( ClientProtocolException e ) {
e . printStackTrace ( ) ;
} c a t c h ( IOException e ) {
e . printStackTrace ( ) ;
}
try {
BufferedReader r e a d e r = new BufferedReader (
new InputStreamReader ( i s , " i s o 88591 " ) , 8 ) ;
S t r i n g B u i l d e r sb = new S t r i n g B u i l d e r ( ) ;
Stri ng l i n e = null ;
while ( ( l i n e = r e a d e r . readLine ( ) ) ! = n u l l ) {
sb . append ( l i n e + " \n " ) ;
}
is . close ( ) ;
j s o n = sb . t o S t r i n g ( ) ;
} catch ( Exception e ) {
Log . e ( " B u f f e r E r r o r " , " E r r o r c o n v e r t r e s u l t " + e . t o S t r i n g ( ) ) ;
}
try {
j O b j = new JSONObject ( j s o n ) ;
} c a t c h ( JSONException e ) {
Log . e ( "JSON P a r s e r " , " E r r o r p a r s i n g data " + e . t o S t r i n g ( ) ) ;
}
return jObj ;
}
actividad 4
1. Para todas las actividades no se olvide de comentar el cdigo
2. Agregamos los atributos, tanto el objeto JSON como los que
vayamos a necesitar de comunicacin con el servidor.
p r i v a t e P r o g r e s s D i a l o g pDialog ;
JSONParser j P a r s e r = new JSONParser ( ) ;
A r r a y L i s t <HashMap< S t r i n g , S t r i n g >> empresaList ;
private s t a t i c String url_all_empresas =
" h t t p :// m i d i r e c c i o n / l a b o r a t o r i o 8 / g e t _ a l l _ e m p r e s a s . php " ;
p r i v a t e s t a t i c f i n a l S t r i n g TAG_SUCCESS = " s u c c e s s " ;
p r i v a t e s t a t i c f i n a l S t r i n g TAG_PRODUCTS = " empresas " ;
p r i v a t e s t a t i c f i n a l S t r i n g TAG_ID = " i d " ;
p r i v a t e s t a t i c f i n a l S t r i n g TAG_NOMBRE = " nombre " ;
JSONArray products = n u l l ;
ListView l i s t a ;
actividad 4
actividad 4
actividad 5
actividad 5
1. Fichero xml main
<LinearLayout
android : layout_width= " f i l l _ p a r e n t "
android : l a y o u t _ h e i g h t = " f i l l _ p a r e n t "
android : o r i e n t a t i o n = " v e r t i c a l " >
<ListView
android : i d= "@+i d/ l i s t A l l P r o d u c t s "
android : layout_width= " f i l l _ p a r e n t "
android : l a y o u t _ h e i g h t = " wrap_content "
android : d i v i d e r H e i g h t = " 3dp "
android : background= " # f f f " />
</LinearLayout >
actividad 6
1. Fichero XML
<LinearLayout
android : layout_width= " f i l l _ p a r e n t "
android : l a y o u t _ h e i g h t = " match_parent "
android : background= " # f 0 f 0 f 0 "
android : o r i e n t a t i o n = " v e r t i c a l " >
<TextView
android : i d= "@+i d/s i n g l e _ p o s t _ t v _ n o m b r e "
android : layout_width= " wrap_content "
android : l a y o u t _ h e i g h t = " wrap_content "
android : l a y o u t _ g r a v i t y = " bottom "
android : paddingBottom= " 2 dip "
android : padding= " 10dp "
android : t e x t C o l o r = " #333 "
android : t e x t S i z e = " 12dp "
android : t e x t S t y l e = " bold "
android : t e x t = " nombre " />
<TextView
android : layout_width= " wrap_content "
android : l a y o u t _ h e i g h t = " wrap_content "
android : textAppearance= " ? android : a t t r /textAppearanceSmall "
android : t e x t = " i d "
android : i d= "@+i d/ s i n g l e _ p o s t _ t v _ i d "
android : v i s i b i l i t y = " gone " />
</LinearLayout >
actividad 6
https://github.com/saravia/BaseDatos
10
practica
practica
1. En esta prctica hemos visto como leer de una BBDD. Se pide
que podamos crear una empresa en nuestra aplicacin y se
verifique en el servidor.
2. Creamos un nuevo campo de BBDD que se va a llamar
descripcin. Modifica tanto la aplicacin como la BBDD del
servidor para que se pueda ver este nuevo campo.
https://github.com/saravia/Laboratorio8_Practica_1
11
Referencias
referencias
[1] Conceptos Android: http://www.ajpdsoft.com/modules.php?
name=News&file=article&sid=603
12