Android Studio App

profilemainbox1
part4..zip

A4.pdf

Part 4

Services

Purpose: The purpose of this assignment is to utilize an Android Service to sync Todos data with a web service

1. Continue existing Todo project

2. Meet the following requirements

You app must fit the description that follows as well as meet the more specific list of requirements.

Your task is to use a Service to sync your Todos with a web service (or fake service). Your service must poll the service on a regular interval and retrieve new Todos from the service. Also, any new Todos that were created by the user should be sent to the service. All sending and receiving will be done using JSON strings. A notification must be displayed when your service ‘downloads’ new Todos. Your app must include a Settings screen for allowing the user to toggle background syncing. You will have the option of using the NodeJS web server or you may use the fake service that is provided as a JAR file. The fake service simulates a real web service. View the Javadocs in the zip file for usage.

Your app must meet the following requirements: 1. Check the service for new Todos and display new Todos in your app. 2. Any new Todos must be placed in your database 3. A notification must be displayed when new Todos are downloaded. Clicking on

the notification should open the main screen of your app. 4. Any new Todos created since the last time you synced should be sent to the

service.

3. (Optional) - Use the NodeJS web server instead of the fake jar service. a. See the previous assignment for setup instruction (nodejs). b. All requirements from above must be met.

Assignment Questions: (answer in a plain text file )

1. Why/When should you use a Service in your application? 2. What is the Service lifecycle? (List the methods in order, started and bound) 3. What is the difference between a Service and an IntentService? 4. When should you display a notification? How do you update an existing notification? 5. Explain how a bound service works.

TodosService/TodosService.jar

META-INF/MANIFEST.MF

Manifest-Version: 1.0

edu/towson/cosc431/valis/imageservice/ImageService.class

                    package edu.towson.cosc431.valis.imageservice;

                    public 
                    synchronized 
                    class ImageService {
    
                    private 
                    static ImageService 
                    ourInstance;
    
                    private 
                    static java.util.concurrent.ConcurrentHashMap 
                    map;
    
                    private java.util.List 
                    data;
    
                    private java.util.Random 
                    random;
    
                    private java.util.List 
                    icons;
    
                    public 
                    static ImageService 
                    getInstance();
    
                    private void ImageService();
    
                    public java.util.List 
                    getAvatars();
    
                    public java.util.List 
                    getAvailableImageIds();
    
                    public void 
                    setImage(String, int);
    
                    public android.graphics.Bitmap 
                    getImage(String);
    
                    static void 
                    <clinit>();
}

                

edu/towson/cosc431/valis/imageservice/TodosService$Todo.class

                    package edu.towson.cosc431.valis.imageservice;

                    synchronized 
                    class TodosService$Todo {
    java.util.UUID 
                    id;
    String 
                    title;
    String 
                    content;
    boolean 
                    completed;
    java.util.Date 
                    createdAt;
    java.util.Date 
                    lastModified;
    void TodosService$Todo(TodosService, String, String);
}

                

edu/towson/cosc431/valis/imageservice/TodosService.class

                    package edu.towson.cosc431.valis.imageservice;

                    public 
                    synchronized 
                    class TodosService {
    
                    private boolean 
                    running;
    
                    public 
                    static int 
                    SLOW;
    
                    public 
                    static int 
                    MEDIUM;
    
                    public 
                    static int 
                    FAST;
    
                    private int 
                    currentIndex;
    
                    private int 
                    speed;
    
                    private Thread 
                    thread;
    
                    private 
                    static TodosService 
                    ourInstance;
    
                    private 
                    static java.text.SimpleDateFormat 
                    sdf;
    
                    private java.util.List 
                    todos;
    
                    private 
                    static int 
                    count;
    
                    private 
                    static java.util.Random 
                    random;
    
                    public 
                    static TodosService 
                    getInstance(int);
    
                    private void TodosService(int);
    
                    private void 
                    start();
    
                    public String 
                    getTodos(String);
    
                    public String 
                    getTodos();
    
                    public void 
                    putTodos(String);
    
                    private String 
                    nextTodo();
    
                    private org.json.JSONObject 
                    toJSON(TodosService$Todo);
    
                    static void 
                    <clinit>();
}

                

edu/towson/cosc431/valis/imageservice/Avatar.class

                    package edu.towson.cosc431.valis.imageservice;

                    public 
                    synchronized 
                    class Avatar {
    
                    private String 
                    name;
    
                    private int 
                    img;
    
                    private int 
                    id;
    
                    public void Avatar(String, int, int);
    
                    public String 
                    getName();
    
                    public void 
                    setName(String);
    
                    public int 
                    getImg();
    
                    public void 
                    setImg(int);
    
                    public int 
                    getId();
}

                

edu/towson/cosc431/valis/imageservice/TodosService$1.class

                    package edu.towson.cosc431.valis.imageservice;

                    synchronized 
                    class TodosService$1 
                    implements Runnable {
    void TodosService$1(TodosService);
    
                    public void 
                    run();
}