You are on page 1of 39

ANHANGUERA EDUCACIONAL

UNIAN UNIVERSIDADE ANHANGUERA PAULISTA

SISTEMAS DE INFORMAO

BRUNO PEREIRA RA 6814001065


DANIEL MASTRODOMENICO RA 6814015174
EDUARDO XAVIER RA 6856494918
FRANCISCO HUGO RA 6444296266
HELBER SCHIMITH RA 6268235461

ATIVIDADES PRTICAS SUPERVISIONADAS


Programao em Dispositivos Mveis

SANTO ANDR
2015

BRUNO NEVES RA 6814001065


DANIEL MASTRODOMENICO RA 6814015174
EDUARDO XAVIER RA 6856494918
FRANCISCO HUGO RA 6444296266
HELBER SCHIMITH RA 6268235461

ATIVIDADES PRTICAS SUPERVISIONADAS


Programao em Dispositivos Mveis

ATIVIDADE PRTICA SUPERVISIONADA DA


MATRIA PROGRAMAO EM DISPOSITIVOS
MVEIS DESTINADA UNIAN UNIVERSIDADE
ANHANGUERA
PAULISTA
- ANHANGUERA
EDUCACIONAL SOB
A ORIENTAO
DO
PROFESSOR CLAUDIO BURANELLO.

SANTO ANDR
2015
2

RESUMO

Ser apresentado a seguir como desafio da Atividade Prtica Supervisionada ATPS,


uma srie de exemplos tericos e prticos sobre a programao em dispositivos mobile com
sistema operacional android. O contedo aqui descrito representa as etapas um e dois da atps
Programao em Dispositivos Mveis, feita por Tiago Teixeira Medeiros da Faculdade de
Negcios e Tecnologia.
Muito comum em nosso dia a dia, os dispositivos moveis simplesmente tornaram-se
elementos indispensveis em muitas situaes rotineiras como na comunicao, auxilio em
tarefas, lembretes, informao, divulgao, interatividade, entre muitos ouros aspectos.
Estas duas etapas da atps que esto presentes neste trabalho so importantes para que
conheamos caractersticas e recursos do desenvolvimento para o android e adquir assim, o
conhecimento de criao de interfaces grficas, manipulao de elementos e navegao nas
Activitys.

SUMRIO

Resumo.................................................................................................................................... 03
ETAPA 1..................................................................................................................................05
Passo 3 - Relatrio 1.3 .............................................................................................05
ETAPA 2 .................................................................................................................................16
Passo 3 - Relatrio 2.3 .............................................................................................16
ETAPA 3 .................................................................................................................................22
Passo 3 - Relatrio 3.3 .............................................................................................22
ETAPA 4 .................................................................................................................................38
Passo 3 - Relatrio 4.3 .............................................................................................38
Concluso.................................................................................................................................39
Bibliografia..............................................................................................................................39

ETAPA 1______________________________________________
Passo 3 - Relatrio 1.3 Entregar um relatrio contendo todo cdigo fonte gerado no Passo 2.
Implementar a classe Desejo conforme diagrama abaixo:

public class Desejo {

this.categoria = categoria;
}

private int _id;


private String poduto;
private String categoria;
private String lojas;
private double precoMinimo;
private double precoMaximo;

public String getLojas() {


return lojas;
}
public void setLojas(String lojas) {
this.lojas = lojas;
}

public int getId() {


return _id;
}
public void setId(int _id) {
this._id = _id;
}
public String getPoduto() {
return poduto;
}

public double getPrecoMinimo() {


return precoMinimo;
}
public void setPrecoMinimo(double
precoMinimo) {
this.precoMinimo =
precoMinimo;
}

public void setPoduto(String


poduto){
this.poduto = poduto;
}

public double getPrecoMaximo() {


return precoMaximo;
}
public void setPrecoMaximo(double
precoMaximo) {
this.precoMaximo =
precoMaximo;
}

public String getCategoria() {


return categoria;
}
public void setCategoria(String
categoria) {

Criar as Activities (apenas a Interface Grfica) abaixo:

Listar Desejos (Activity Principal)


Inserir Desejo
Detalhes do Desejo
Alterar Desejo

Uma activity o componente responsvel por mostrar uma tela ao usurio.

Activity Listar Desejos (Activity Principal):

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:id= " @ + id / button_criarP "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / criar_p " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/nome_produto" />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/categoria" />
6

<Button
android:id= " @ + id / button_detalharP "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / detalhar_p " />
</LinearLayout>

Activity Inserir Desejo:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/nome_produto" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/categoria" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/preco_minimo" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/preco_maximo" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/lojas" />
8

<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/salvar" />
</LinearLayout>

Activity Detalhar Desejo:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:id= " @ + id / button_alterarP "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / alterar_p " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/nome_produto" />
<TextView
android:id= " @ + id / show_nome "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_nome "
android:visibility= " invisible " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/categoria" />
<TextView
10

android:id= " @ + id / show_categoria "


android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_categoria "
android:visibility= " invisible " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/preco_minimo" />
<TextView
android:id= " @ + id / show_preco_minimo "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_preco_minimo "
android:visibility= " invisible " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/preco_maximo" />
<TextView
android:id= " @ + id / show_preco_maximo "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_preco_maximo "
android:visibility= " invisible " />
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/lojas" />
11

<TextView
android:id= " @ + id / show_lojas "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_lojas "
android:visibility= " invisible " />
</LinearLayout>

12

Activity Alterar Desejo:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/nome_produto" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/categoria" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/preco_minimo" />
<EditText
android:layout_width="match_parent"
13

android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/preco_maximo" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/lojas" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/salvar" />
</LinearLayout>

14

Resources

<? xml version = " 1.0 " encoding= " utf -8 " ?>
<resources>
<string name= " app_name " >Lista de Desejos</string>
<string name= " name_produto " > Nome do Produto </string>
<string name= " categoria " > Categoria </string>
<string name= " preco_minimo " > Preo Mnimo </string>
<string name= " preco_maximo " > Preo Mximo </string>
<string name= " lojas " > Lojas </string>
<string name= " salvar " >Salvar</string>
<string name= " criar_p " > Ciar Desejo </string>
<string name= " alterar_p " > Alterar Desejo </string>
<string name= " detalhar_p " > Detalhar Desejo </string>
</resources>

15

ETAPA 2______________________________________________
Passo 3 Relatrio 2.3 Contedo do cdigo fonte gerado no Passo 2.
Usar Intents para programar a navegao entre as Activities criadas na etapa anterior:

Listar Desejos (Activity Principal)


Inserir Desejo
Detalhes do Desejo
Alterar Desejo

Intents Listar Desejos (Activity Principal)

package br.com.Lista.de.Desejos;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ListarDesejoMainActivity1 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button = (Button) findViewById(R.id.button_criarP);

button.setOnClickListener( new OnClickListener() {

16

public void onClick(View v) {


Intent intent = new Intent(ListarDesejoMainActivity1.this ,
InseriDesejoActivity2.class);
startActivity(intent);
}

Button button = (Button) findViewById(R.id.button_detalharP);

button.setOnClickListener( new OnClickListener() {

public void onClick(View v) {


Intent intent = new Intent(ListarDesejoMainActivity1.this ,
DetalharDesejoActivity2.class);
startActivity(intent);
}
});
}
}

17

Intents Inserir Desejos

package br.com.Lista.de.Desejos;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class InseriDesejoActivity2 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}

18

Intents Detalhar Desejos


package br.com.Lista.de.Desejos;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DetalharDesejoActivity1 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.button_alterarP);

button.setOnClickListener( new OnClickListener() {

public void onClick(View v) {


Intent intent = new Intent(DetalharDesejoActivity1.this ,
AlterarDesejoActivity2.class);
startActivity(intent);
}
});
}
}

19

package br.com.Lista.de.Desejos;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class DetalharDesejoActivity2 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}

20

Intents Alterar Desejos

package br.com.Lista.de.Desejos;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class AlterarDesejoActivity2 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}

21

ETAPA 3______________________________________________
Passo 3 Relatrio 3.3 Contedo do cdigo fonte gerado no Passo 2.
ListarDesejos Deve ser capaz de consultar todos os desejos cadastrados no banco
de dados e exibir na Activity atravs de um ListView (ou similar).
AdicionarDesejo Deve ser capaz de incluir um desejo no banco de dados.
DetalharDesejo Deve ser capaz de exibir os detalhes do Desejo. A partir dessa
Activity, deve ser possvel ir para a Activity Alterar Desejo e acionar a funcionalidade
Excluir Desejo.
AlterarDesejo Deve ser capaz de alterar os dados de um Desejo previamente
cadastrado no banco de dados.
Programar a funcionalidade Excluir Desejo Deve ser capaz de excluir um desejo
previamente cadastrado no banco de dados.

ListarDesejo.java
package br.com.Lista.de.Desejos;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;

22

public class ListarDesejo extends {


private ListView obj;
OperadorBancoDados mydb;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.LinearLayout.ListarDesejo);

mydb = new OperadorBancoDados(this);


ArrayList array_list = mydb.getAllCotacts();
ArrayAdapter arrayAdapter=new
ArrayAdapter(this,android.R.layout.simple_list_item_1, array_list);

obj = (ListView)findViewById(R.id.listView1);
obj.setAdapter(arrayAdapter);
obj.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {

int id_To_Search = arg2 + 1;

Bundle dataBundle = new Bundle();


dataBundle.putInt("id", id_To_Search);

Intent intent = new


Intent(getApplicationContext(),br.com.Lista.de.Desejos.class);

23

intent.putExtras(dataBundle);
startActivity(intent);
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item){
super.onOptionsItemSelected(item);

switch(item.getItemId())
{
case R.id.item1:Bundle dataBundle = new Bundle();
dataBundle.putInt("id", 0);

Intent intent = new


Intent(getApplicationContext(),br.com.Lista.de.Desejos.class);
intent.putExtras(dataBundle);

startActivity(intent);
24

return true;
default:
return super.onOptionsItemSelected(item);
}
}

public boolean onKeyDown(int keycode, KeyEvent event) {


if (keycode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
}
return super.onKeyDown(keycode, event);
}
}

25

DetalharDesejo.java
package br.com.Lista.de.Desejos;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class DetalharDesejo extends Activity {


int from_Where_I_Am_Coming = 0;
private OperadorBancoDados mydb ;

TextView show_nome ;
TextView show_categoria;
TextView show_preco_minimo;
TextView show_preco_maximo;
TextView show_lojas;
int id_To_Update = 0;

26

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.LinearLayout.ListarDesejo);
show_nome = (TextView) findViewById(R.id.editTextshow_nome);
show_categoria = (TextView) findViewById(R.id.editTextshow_categoria);
show_preco_minimo = (TextView)
findViewById(R.id.editTextshow_preco_maximo);
show_preco_maximo = (TextView)
findViewById(R.id.editTextshow_preco_minimo);
show_lojas = (TextView) findViewById(R.id.editTextshow_lojas);

mydb = new OperadorBancoDados(this);

Bundle extras = getIntent().getExtras();


if(extras !=null)
{
int Value = extras.getInt("id");

if(Value>0){

Cursor rs = mydb.getData(Value);
id_To_Update = Value;
rs.moveToFirst();

String show_nom =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_nome));

27

String show_categori =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_categori
a));
String show_preco_minim =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_preco_m
inimo));
String show_preco_maxim =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_preco_m
aximo));
String show_loja =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOSS_COLUMN_show_lojas));

if (!rs.isClosed())
{
rs.close();
}
Button b = (Button)findViewById(R.id.button1);
b.setVisibility(View.INVISIBLE);

show_nome.setText((CharSequence)show_nom);
show_nome.setFocusable(false);
show_nome.setClickable(false);

show_categoria.setText((CharSequence)show_categori);
show_categoria.setFocusable(false);
show_categoria.setClickable(false);

show_preco_minimo.setText((CharSequence)show_preco_minim);
show_preco_minimo.setFocusable(false);
show_preco_minimo.setClickable(false);
28

show_preco_maximo.setText((CharSequence)show_preco_maxim);
show_preco_maximo.setFocusable(false);
show_preco_maximo.setClickable(false);

show_lojas.setText((CharSequence)show_loja);
show_lojas.setFocusable(false);
show_lojas.setClickable(false);
}
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

Bundle extras = getIntent().getExtras();

if(extras !=null)
{
int Value = extras.getInt("id");
if(Value>0){
getMenuInflater().inflate(R.menu.DetalharDesejo, menu);
}

else{
getMenuInflater().inflate(R.menu.ListarDesejo, menu);
}
29

}
return true;
}

public boolean onOptionsItemSelected(MenuItem item)


{
super.onOptionsItemSelected(item);
switch(item.getItemId())
{
case R.id.AlterarDesejo:
Button b = (Button)findViewById(R.id.button1);
b.setVisibility(View.VISIBLE);
show_nome.setEnabled(true);
show_nome.setFocusableInTouchMode(true);
show_nome.setClickable(true);

show_categoria.setEnabled(true);
show_categoria.setFocusableInTouchMode(true);
show_categoria.setClickable(true);

show_preco_minimo.setEnabled(true);
show_preco_minimo.setFocusableInTouchMode(true);
show_preco_minimo.setClickable(true);

show_preco_maximo.setEnabled(true);
show_preco_maximo.setFocusableInTouchMode(true);
show_preco_maximo.setClickable(true);
30

show_lojas.setEnabled(true);
show_lojas.setFocusableInTouchMode(true);
show_lojas.setClickable(true);

return true;
case R.id.Delete_Desejo:

AlertDialog.Builder builder = new AlertDialog.Builder(this);


builder.setMessage(R.string.deleteDesejo)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mydb.deleteDesejo(id_To_Update);
Toast.makeText(getApplicationContext(), "Deletado com Sucesso! ",
Toast.LENGTH_SHORT).show();
Intent intent = new
Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
startActivity(intent);
}
})
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {

}
});
AlertDialog d = builder.create();
d.setTitle("Are you sure");
d.show();
31

return true;
default:
return super.onOptionsItemSelected(item);

}
}

public void run(View view)


{
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
int Value = extras.getInt("id");
if(Value>0){
if(mydb.updateDesejo(id_To_Update,show_nome.getText().toString(),
show_categoria.getText().toString(), show_preco_minimo.getText().toString(),
show_preco_maximo.getText().toString(), show_lojas.getText().toString())){
Toast.makeText(getApplicationContext(), "Updated",
Toast.LENGTH_SHORT).show();
Intent intent = new
Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
startActivity(intent);
}
else{
Toast.makeText(getApplicationContext(), "not Updated",
Toast.LENGTH_SHORT).show();
}
}
32

else{
if(mydb.insertDesejo(show_nome.getText().toString(),
show_categoria.getText().toString(), show_preco_minimo.getText().toString(),
show_preco_maximo.getText().toString(), show_lojas.getText().toString())){
Toast.makeText(getApplicationContext(), "done",
Toast.LENGTH_SHORT).show();
}

else{
Toast.makeText(getApplicationContext(), "not done",
Toast.LENGTH_SHORT).show();
}
Intent intent = new
Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
startActivity(intent);
}
}
}
}

33

OperadorBancoDados.java
package com.example.addressbook;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteOperadorBancoDados;
import android.database.sqlite.SQLiteDatabase;

public class OperadorBancoDados extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "MyDBDesejos.db";


public static final String DESEJOS_TABLE_DESEJOS = "desejos";
public static final String DESEJOS_COLUMN_ID = "id";
public static final String DESEJOS_COLUMN_SHOW_NAME = "show_nome";
public static final String DESEJOS_COLUMN_SHOW_CATEGORIA =
"show_categoria";
public static final String DESEJOS_COLUMN_SHOW_PRECO_MINIMO =
"show_preco_minimo";
public static final String DESEJOS_COLUMN_SHOW_PRECO_MAXIMO =
"show_preco_maximo";
public static final String DESEJOS_COLUMN_SHOW_LOJAS = "show_lojas";
private HashMap hp;

34

public OperadorBancoDados(Context context){


super(context, DATABASE_NAME , null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(
"create table desejos " +
"(id integer primary key, show_nome text,show_categoria
text,show_preco_minimo text, show_preco_maximo text,show_lojas text)"
);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS desejos");
onCreate(db);
}
public boolean insertDesejos (String show_nome, String show_categoria, String
show_preco_minimo, String show_preco_maximo,String show_lojas)
{ SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("show_nome", show_nome);
contentValues.put("show_categoria", show_categoria);
contentValues.put("show_preco_minimo", show_preco_minimo);
contentValues.put("show_preco_maximo", show_preco_maximo);
contentValues.put("show_lojas", show_lojas);
db.insert("desejos", null, contentValues);
return true;
}
35

public Cursor getData(int id){


SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select * from desejos where id="+id+"", null );
return res;
}

public int numberOfRows(){


SQLiteDatabase db = this.getReadableDatabase();
int numRows = (int) DatabaseUtils.queryNumEntries(db,
DESEJOS_TABLE_NAME);
return numRows;
}
public boolean updatedesejo (Integer id, String show_nome, String show_categoria,
String show_preco_minimo, String show_preco_maximo,String show_lojas)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("show_nome", show_nome);
contentValues.put("show_categoria", show_categoria);
contentValues.put("show_preco_minimo", show_preco_minimo);
contentValues.put("show_preco_maximo", show_preco_maximo);
contentValues.put("show_lojas", show_lojas);
db.update("desejos", contentValues, "id = ? ", new String[] { Integer.toString(id) }
);
return true;
}

36

public Integer deletedesejo (Integer id)


{
SQLiteDatabase db = this.getWritableDatabase();
return db.delete("desejos",
"id = ? ",
new String[] { Integer.toString(id) });
}

public ArrayList<String> getAllCotacts()


{
ArrayList<String> array_list = new ArrayList<String>();

//hp = new HashMap();


SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select * from desejos", null );
res.moveToFirst();

while(res.isAfterLast() == false){

array_list.add(res.getString(res.getColumnIndex(DESEJOS_COLUMN_NAME)));
res.moveToNext();
}
return array_list;
}
}

37

ETAPA 4______________________________________________
Passo 3 Relatrio 4.3 Contedo do cdigo fonte gerado no Passo 2.

<item
android:id="@+id/menu_item_share"
android:showAsAction="ifRoom"
android:title="Share"
android:actionProviderClass="android.widget.ShareActionProvider"
/>
------------------------------------------------------------------------

private ShareActionProvider mShareActionProvider;


@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_menu, menu);

MenuItem item = menu.findItem(R.id.menu_item_share);

mShareActionProvider = (ShareActionProvider) item.getActionProvider();

return true;
}
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}

38

CONCLUSO
O contedo exposto o resultado do desenvolvimento proposto na ATPS. Os
exemplos implementados foram feitos com a ajuda do contedo proposto pela atps e tambm
sites na internet. Contedo este, que foi fundamental para o desenvolvimento dos exemplos.

BIBLIOGRAFIA
Livro k19 k41. Desenvolvimento mobile com android.
LEE, Wei Meng. Introduo ao Desenvolvimento de Aplicativos para o Android. 1
ed. So Paulo: Cincia Moderna, 2011.
SANTOS, Rafael. Introduo Programao Orientada a Objeto Utilizando Java. 1
ed. Rio de Janeiro: Campus - Elsevier, 2003, v.1.
DEITEL, P. J.; DEITEL, Harvery M.. C: Como Programar. 6 ed. So Paulo: Pearson,
2011.
CADENHEAD, Rogers. Aprenda em 21 dias Java 2. 4 ed. Rio de Janeiro: Elsevier,
2005.
RESENDE, Antnio Maria Pereira. Programao Orientada a Aspectos em Java:
Desenvolvimento de Software Orientado a Aspectos. 1 ed. Rio de Janeiro: Brasport, 2005.
NIEMEYER, Patrick. Aprendendo Java 2 SDK: verso 1.3. 1 ed. Rio de Janeiro:
Campus, 2000.
TUTORIAL Android Parte 3 Construo de Telas por Renan Drabach
< http://www.mobiltec.com.br/blog/index.php/tutorial-android-parte-3-construcao-de-telas/ >
Acesso em: 04 Abril. 2015
Android Developers Training por Google
< http://developer.android.com/training/index.html >
Acesso em: 04 Abril. 2015
Android - SQLite Database Tutorial
< http://www.tutorialspoint.com/android/android_sqlite_database.htm >

39

You might also like