Android application locates Facebook friends on a Google map - Technical Report A Bachelor's Thesis at the University of Crete
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Android application locates Facebook friends on a Google map Technical Report A Bachelor’s Thesis at the University of Crete Department of Computer Science Author: Darío Ortuño Esplugues Advisor: Maria Papadopouli Date: 24/06/2011
Abstract: The social networks are present in the life more and more people, each time the use of mobile devices allows access to these social networks from many places and with the use of technologies as GPS we can realize together with the capacity of offer geographic locations that have the Location Based Services applications that can locate the user and his friends in the social networks. We aim to further understand the Android platform, Location Based Services, Facebook Platform, Google Maps and create an application capable of locating the current location user and his friends of Facebook in a Google Map, will use the locations provides by Facebook and using these like a GPS trace. The user will be able to publish his current location always that is possible because arise any problem with the features of Facebook to achieve this characteristics in any place. And we find a slow execution due to the amount of necessary request to check the location of all the friends of the user. But finally we can see an application fully operative and functional that periodically updates the users locations to get a real-time application. 2
Contents 1 Introduction ................................................................................................................. 4 2 Operating System ........................................................................................................ 5 3 Technologies Overview ............................................................................................... 7 3.1 Location Based Services......................................................................................... 7 3.1.1 Development of Location Based Services....................................................... 7 3.1.2 LBS Components............................................................................................. 8 3.1.3 LBS features .................................................................................................... 9 3.2 Android................................................................................................................. 10 3.2.1 Architecture ................................................................................................... 10 3.2.2 Application Components ............................................................................... 12 3.3 Facebook............................................................................................................... 13 3.4 Google Maps ........................................................................................................ 15 4 Application ................................................................................................................. 16 4.1 Application Overview: Find Your Facebook Friends .......................................... 16 4.2 Android Platform.................................................................................................. 17 4.3 Facebook Features ................................................................................................ 19 4.3.1 Authentication ............................................................................................... 19 4.3.2 Requests and Responses ................................................................................ 20 4.3.3 Publish checkin.............................................................................................. 21 4.4 Google Maps Platform ......................................................................................... 22 4.4.1 Google Maps Activity ................................................................................... 22 4.4.2 Class MapView ............................................................................................. 22 4.4.3 User current location ..................................................................................... 22 4.4.4 User Friends Locations.................................................................................. 23 5 Results and discussion ............................................................................................... 24 6 Conclusions ................................................................................................................ 27 7 Future work ............................................................................................................... 28 7.1 Enhancing the performance .................................................................................. 28 7.2 Publishing checkins .............................................................................................. 28 7.3 Drawing the path .................................................................................................. 28 Bibliography.................................................................................................................. 29 Appendix ....................................................................................................................... 30 A. Creating Facebook Application for Android ...................................................... 30 B. Registering Facebook Application......................................................................... 32 C. Obtaining Google Maps API Key ...................................................................... 33 3
1 Introduction Each time the social networks are more used by all kind of people, the growing use of Smartphones makes that is possible access to the different social networks in any place, we are interesting too in the possibility of this kind of devices because you can use the GPS services easily, and if we add the potential of the location based service, we can see a lot of capabilities. The location based (Section 3.1) service are based in the capacity of offer geographic location information using Geographic Information Systems utilizing in our case GPS and the communication networks technology to transmit information to an application that can process and answer the request, the typical software provides geographical services in real time. We focus our work in the combination of all these technologies to develop an application that is able to allow locate the Facebook friends in a map showing who is online, idle or offline, specifically in a Google Map. The application will update friends in the map periodically. Other features will be the possibility of show the messages written by the users and the timestamp when was published this information in the indicated place. In this software we assume that each mobile device provide a GPS trace, coordinates and timestamps, the idea is recover the current location of the users through Facebook and draw the location of these GPS trace in a Google map using an Android device. To be able to combine these technologies we will use the different APIs that provides Facebook, Google and Android. In the first place, we will speak about Android, is an operating system and a software platform based on Linux kernel developed by Google Inc. Google provides a specific API to work with Google Maps on Android. On the other hand, Facebook supplies a SDK to Android and the Graph API that allow realize request to recover data about the users and yourself. We will see the following steps to develop an application with the characteristics mentioned above, we have to create an Android application combining the Facebook features, such as, log in, authorize the application, reading and writing user data as profile information, but above all the checkin data. The checkins represents an object with locations represented by Facebook Pages or Open Graph protocol pages that we will use to locate the users in the map. Also, we have used the Google Maps features to implement a map where we draw the Facebook users, using the coordinates provides by the above mentioned checkins. We have find problems with the performance to load the users data because requires a lot of request if the user has many Facebook friends, another problem with Facebook characteristics is unable create a checkin if the current place does not have a Facebook page previously created because Facebook API is not able to create Facebook pages, only is possible from the website. 4
In the sections 4 and 5 we will explain more detail how we have develop the application and how we have fixed these problems. And in the next section we discuss the more interesting Operating system to implement the application. 2 Operating System We have developed this application for Android operating system (Section 2.2), to select this operating system instead of any other OS, we have consider the relationship between Google maps (Section 2.4) and Facebook APIs. And for example, Android have a close relationship with Google Maps, so is an operating system of Google. And speaking about the relationship with Facebook, we can implement a Facebook application for Android using Facebook Graph API (Section 2.3) easily. In addition, currently Android OS is one of the most used mobile operating system by the users, as Table 1 and Figure 1 shows. Symbian Windows Source Date BlackBerry iOS Android OS Phone Gartner Q3 2010 36.6% 14.8% 16.7% 25.5% 2.8% Canalys Q3 2010 33% 15% 17% 25% 3% Table 1. Share of smartphone OSs,not overall marketshare Now we discuss what is the better version of Android to develop our application, we can see the statistics that provides Google Inc. , Figure 2 shows the percentages of Android devices with different versions of this operating system. We find a great difference between the various Android versions, the most significant versions are Android 2.2 and 2.1, having Android 2.2 the higher percentage. Further, Figure 3 shows the historical distribution of the relative number of active Android devices running different versions of the Android platform. 5
So, analysing these statistics we have decided use the platform Android 2.2 Froyo to develop our application because is the current version more used in the current Android devices. Figure 2: Android Versions statistics Figure 3: Android Versions historical distribution We have implemented the application with Java programming language because Android applications are developed using this programming language, Java is a programming language object-oriented developed by Sun Microsystems, as object- oriented we understand that both data and code are combined in entities called objects. We can see an object as a package that contains the behaviour (code) and the status (data) . In the next section we introduce the technologies used to be able to have a better vision of the problem discussed in this paper. 6
3 Technologies Overview In this section we will see the technologies used to develop our application with the intention of the reader understands better the issues discussed. 3.1 Location Based Services The Location Based Services (LBS) provides a personalized service to users based in the most situations in geographic location information of them. These services use Geographic Information Systems technology, any technology of positioning either client side, as GPS, or server side, as positioning service provided for the network operator, and communication technology of networks to transmit information to a LBS application that can process and answer the request. The typical LBS applications provide geographic services in real time. 3.1.1 Development of Location Based Services There are three generations of location services: First generation: Require the user introduces manually the location as an address or postal code. Second generation: Are able to determine the location in a general form typically as a postal code. Third generation: Dispose of location information more accurate and have the capacity of initiate services proactively based on the location. These services are launched by triggers and can notify the user of events or relevant conditions without the user having to actively participate. 7
3.1.2 LBS Components We can find five basic components as shown the Figure 4: Mobile Devices: The possible devices are Mobile Phones, PDA’s, Laptops, navigation unit of car,… Is a tool for the user to request the needed information. Communication Network: Mobile network which transfer the user data and service request from the mobile device to the service provider and the request information back to the user. Positioning Component: To determine the user position can be obtained by using the Global Positioning System or by using the mobile communication network. There are additional possibilities to determine the position are active badges, WLAN stations or radio beacons. Service and Application Provider: The service provider offers a number of different services to the user and is responsible for the service request processing. Such services offer the calculation of the position, finding a route, searching yellow pages with respect to position or searching specific information on objects of user interest . Data and Content Provider: Service providers will usually not store and maintain all the information which can be requested by users. Therefore geographic base data and location information data will be usually requested from the maintaining authority or business and industry. Figure 4: The basic components of an LBS 8
3.1.3 LBS features In this section we see the different locating characteristics, these are: Geocoding (Acquisition by address): Determines the latitude and longitude of an address and allows geographic information associated. Reverse geocoding: uses a coordinate (latitude, longitude) to return other information as well as related geographic information. Routing (Route Planning): Select one route with shortest distance or travel time according to the source, destination, via one location. Delivery navigation instructions step by step based on a point of origin and destination, can be considered as external variables and dynamic information on traffic congestion and incidents. Map Service: Display maps, move, zoom in / zoom out with high quality and ability to query geographic information to a site via a click on it. Find the nearest (Search by Neighbourhood): Returns features based on geographical nearest a given location. Manually or automatically select a target to see nearby points of interest. Directory Services Acquisition (by rank): identifies a business within a geographic region. Find points of interest within a given range. Tracking services (tracking): to provide positioning information for the mobile client and store the record of the route. 9
3.2 Android Android is a complete set of software contains an operating system, middleware and key applications on Linux kernel, designed originally for mobile devices, Android has the most of its code under the Apache License, free software and open source license. The Android system lets develop applications in a Java and are running on a Dalvik virtual machine with compilation on execution time. 3.2.1 Architecture Figure 5 shows as is divided the architecture of Android, we can find these components: Applications: All applications built with the Android platform as a base include an email client (email), calendar, SMS program, maps, browser, contacts, and some other basic services. Everything is written in the Java programming language. Frameworks of applications: All developers of Android applications have full access to the source code used in basic applications. This has been designed this way, so as not to generate hundreds of different application components that respond to the same action, giving the possibility that programs be modified or replaced by any user without having to start coding their applications from the beginning. All applications are a set of systems and services, with a set of Views extensible to build and application including text boxes, buttons… Also we find Content Providers that let to access to the data from another applications. Resource Manager presents access to resources such as strings, graphics, and layouts. In addition we find a Notification Manager provides custom alerts in the status bar. Finally, we can see an Activity Manager that lets a common navigation backstack and administrate the lifecycle of applications. Libraries: Android includes in its database a set of libraries C / C + +, which are exposed to all developers through the framework of the applications Android System C library, Media Libraries, Surface Manager, LibWebCore, SGL, 3D libraries, FreeType and SQLite. Android Runtime: Android includes a set of libraries that provide most of the features available in libraries base Java programming language. Dalvik Virtual Machine has been implemented so that a device can run multiple Virtual Machines efficiently, this Virtual Machine executes files optimized for minimal memory footprint, Dalvik Executable (.dex). The Virtual Machine is register- based and runs classes compiled by a Java language compiler. 10
Linux kernel: Android depends of Linux version 2.6 for the base service of the system as security, memory management, process Management, network stack and driver model. The kernel work too as an abstraction layer between the rest of software stack and hardware. Figure 5: Android Architecture As mentioned above the applications of Android are written with the programming language Java, with the SDK tools of Android the code is compiled into an Android package (.apk), this package may be install in Android devices. The operating system consider each application like an unique Linux user, each application runs in its own process, which will run in isolation from another. 11
3.2.2 Application Components Now we discuss about the application components, the components are a unique part that help to define the global behaviour, the different components are the next: Activities: An activity provides a screen to interact with the application, normally an application have various activities being one the main activity which usually will be shown in the first time. Services: Is a component that not supplies an interface if not realize a long- running operations in the background. Any application component can start a service and it will work in the background even the user opens another application. A service can be of two forms, started and bound. The started services can run even the component that started the service is destroyed, normally this kind of services does not return a result. On the other hand a bound service provides a client-server interface that allows components to interact with the service, sending requests, getting results, even doing these operations using interprocess communication (IPC). If the component that starts this service is destroyed this kind of service will be finished. Content providers: A content provider manages a shared set of application data, can store and retrieve data and make it accessible to all applications. When we want to make our data public, we have two options. In the first case we can create our own content provider or add the data to an existing provider. Broadcast receivers: A broadcast receiver responds to system-wide broadcast announcements, this kind of components do not supply a user interface, although a broadcast receiver may create a status bar notification to alert the user when a broadcast event occurs. Before an Android component can start, the system must know that components exists, an application must declare all its components in the manifest file (AndroidManifest.xml), in addition the manifest can have declared, user permissions that the application requires, the minimum API Level, the hardware and software features required by the application and the API libraries. 12
3.3 Facebook Facebook Platform provides SDKs for iOS and Android, has the possibility for others mobile devices that just can access using the web browser develop applications using the web-based functions. We focus this section in Facebook SDK for Android and any web-based functions such as OAuth2.0, Graph API, Dialogs and Facebook Query Language. The first step to develop an application with Facebook for Android, after install the SDK and realize the steps show in [Appendix A] and registering your application as we can see in [Appendix B], is authenticate using Oauth2.0, the feature that lets the user sign in the application is called Single-Sign-On (SSO), SSO allow the application access to the user information if the user wants using the special permission such as new feeds, friends activities… This function shows a dialog to allow or not these permissions. Once authenticate, we read or write data to Facebook using Graph API, it is the core of Facebook Platform called social graph. Graph API consist in a view of objects (people, pages, events…) and the relationships between them (friend relationships, photo tags…). To access these objects or connections we can use the unique IDs or the names of them using the next URL “https://graph.facebook.com/IDorName”. All responses are JSON objects [json.org], which is a lightweight data-interchange format. The Figure 6 shows the format of a response. Figure 6: Response of https://graph.facebook.com/192928685522 or https://graph.facebook.com/platform 13
On the other hand, we can access to features not available in Graph API using Facebook Query Language (FQL). FQL allows use a SQL-style interface to query the data. We will use this URL to do the queries “https://api.facebook.com/method/fql.query?query=QUERY” . You can specify a response format as either XML or JSON with the format query parameter. Queries are of the form SELECT [fields] FROM [table] WHERE [conditions]. Unlike SQL, the FQL FROM clause can contain only a single table. 14
3.4 Google Maps Google Maps is an application server of maps, that offer powerful cartographic technology, it has features as interact with the map, satellite imagery, route creation, multiview, ride finger. We are interested in the development characteristics, Google Inc. supply different API how we see below. Google Maps API family is composed of Maps Data API that include Java and JavaScript API, Maps API for flash, Google Earth API, Static Maps API, Web Services. However, we are interesting in Google APIs Add-On, is an extension to the Android SDK development environment that lets implement applications for devices that include Google's set of custom applications, libraries, and services. The main feature is the Maps external library, which lets add powerful mapping capabilities to Android applications. The Google APIs add-on includes: The Maps external library, the classes of this library offer built-in downloading, rendering, and caching of Maps tiles, as well as a variety of display options and controls. The main class is MapView, which display a map with data obtained from the Google Maps service. The USB Open Accessory Library, USB accessory mode allows users to connect USB host hardware specifically designed for Android-powered devices. To use the Google Maps services used by the API is necessary generate a key using your MD5 fingerprint[Appendix C] and we will be indispensable install this add-on in your work environment. 15
4 Application 4.1 Application Overview: Find Your Facebook Friends Our application consist in an Android application is able to locate the Facebook friends of a Facebook user in a Google Map. The application will use the checkins of the users friends to draw them in the map with a star. The checkins are associated with locations represented by Facebook Pages, the software obtain the information necessary to draw the user in him last known location such as the coordinates, timestamp, name of the place and message written. Primarily the user must sign in with him Facebook information, username and password, and accept the permissions used by the application such as him own checkin data, checkin information and online presence of him friends and permission to publish checkins in Facebook. Once signed in Facebook the application will display the map and a message to warn that the program is loading the user location friends, when this process is finished the locations friends will be drawn in the map, with different colored stars, if a friend is online in this moment the star will be red, otherwise if a friend is offline we can see a gray star and if the is idle the mark will be blue. To draw the current user location the software has as mark a blue flashing circle. The locations of user friends will be updated time to time, depending on the number of friends or the quality on the network channel. Moreover, the user will be able to publish him current location in Facebook and then, others users that are using this application will see where he is now. To publish the current location should have a Facebook page created in the current coordinates or close to it, because Facebook does not allow create pages with its API, only is possible create a page from Facebook website. In the chapter 5 we can see this and others problems and the used solutions. In the next sections 4.2, 4.3, 4.4 we discuss about the different platform used and how we have used their features to develop this application. 16
4.2 Android Platform Using the Android Application Framework we has developed a sofware is able to connect to internet to recover information of Facebook and connect with GPS to know the current location of the user. The application consist of an Android Activity that lets the user interact with the application and displays him Facebook friends in a Google Map. This activity will be responsible for interacting with the Facebook services such as allow the user authentication, the current location publishing, request users information and parse it. In addition the activity will be able to use the Google Maps features such as create the map, initialize this map, draw the different locations. We see how to use these features as Facebook and Google Maps in Section 4.3 and 4.4. For the application can connect to the internet we must add to the Android Manifest file the next permission: On the other hand, to connect with the GPS services we must add these permissions: Finally, the application will be able to use the Google Maps methods adding the Google Maps library with the next code: And to use the Facebook services we must create an Android project using an example of Facebook that we can find in the SDK folder and after use it as a library [Appendix A]. 17
In the application will be necessary refresh the location information of the user friends each an interval of time, for this we will use a class (LoadFriends) that extends of the Java class TimerTask, this class represents a task to run at a specified time public class LoadFriends extends TimerTask{ private Timer timer; private long seconds; public LoadFriends(long sec) throws ParseException { this.seconds = sec; long initialDelay = seconds * 1000; //miliseconds long period = seconds * 1000; //miliseconds timer = new Timer(); timer.schedule(this, initialDelay, period); } @Override public void run() { if(update == true) { update = false; } else { Log.d(DEBUG_TAG, "Cannot refresh"); } } } Each time the application measures the time spent in loading the users friends because each user will have a different number of friends or the internet connection can be more or less fast depending of the networks condition or of the kind of network. In this manner the application ensures that if for example the network connection is slow the software updates the information in a greater time. Too, we ensure that the application does not update the information if it is updating in the same moment. The application stores the users information using two classes, the first one is the user class that stores the Facebook user id, Facebook name, a list of Facebook checkins, status and if he has or not checkin. The status is the online presence in the current moment in Facebook, the possibles values are active, idle or offline. The list of checkins is a ArrayList of objects of the class Checkin, this list performs the function of GPS trace. The class Checkin is used to store the information of the users location, this class has as attributes Facebook checkin id, a place name, the message written by the user when he did the checkin, the latitude and longitude where he did the checkin and a timestamp that represents when the user did it. 18
4.3 Facebook Features Our application use different services of Facebook, to use these features we must register the application in Facebook and export the signature of the application to ensure the users just are communicating with the application [Appendix B] and we obtain an application identifier that must use to create our Facebook software. 4.3.1 Authentication The first feature of the Facebook SDK is Single-Sign-On (SSO). SSO lets the user sign into the application using him Facebook account. Once authenticate the application will allow do requests about the friends data such as the checkins, online presence and can publish a chekin. In the code application we can see function used to sign with Facebook identity and the permissions used to allow the above characteristics facebook.authorize(this, new String[] { "user_checkins", "friends_checkins", "friends_online_presence", "publish_checkins", "publish_stream" }, new DialogListener() { @Override public void onComplete(Bundle values) {} @Override public void onFacebookError(FacebookError error) {} @Override public void onError(DialogError e) {} @Override public void onCancel() {} }); The code show the permission to recover checkin information (user_ and friends_checkins), know the online presence of the users (friends_online_presence) and to publish a checkin or a stream in the Facebook wall (publish_checkins, publish_stream). 19
4.3.2 Requests and Responses In Facebook SDK realize the request using the Graph API, it consists in a view of objects and the relationships between them. In the application we need know the user information to be able to get the user name and him checkins, the requests are a asynchronous calls with a Graph API url mAsyncRunner.request("me", new MeRequestListener()); In this case, the real url where the application request is https://graph.facebook.com/me, the response will be sent to the request listener, the Graph API responses are JavaScript Object Notation (JSON) objects, which is a lightweight data-interchange format. The application after recover the user information will be another request (me/friends) to get the list of the friends, we will obtain the ID and Name of the users friends, with the identifier we can get the checkins of the friends doing another ask to the Graph API, the users that have one or more checkins will be the users that will be locate in the map because are the unique that have coordinates to locate. On the other hand, we mark the users by online presence, this information can be accessed using a request but applying Facebook Query Language (FQL), FQL allow use a SQL-style interface to query the data, we can see how we ask to the data base Bundle params = new Bundle(); params.putString("method", "fql.query"); params.putString("query", "SELECT online_presence FROM user WHERE uid=" + id); String resp = facebook.request(params); 20
4.3.3 Publish checkin The application will be able to publish the current location of the user, for this the application has at all times the current position of the mobile device, how we discuss in previous sections, Facebook has objects called checkins which are associated with Facebook pages, these pages have parameters such as id, name, category, likes, location, phone and checkins. So, to publish a checkin the application looks for a place that is associated with a page near the current coordinates, for this it do a request using the Graph API Bundle params = new Bundle(); params.putString("access_token", facebook.getAccessToken()); params.putString("type", "place"); params.putString("center", myLocOverlay.getMyLocation().getLatitudeE6() / 1E6 + "," + myLocOverlay.getMyLocation().getLongitudeE6() / 1E6); String response; response = facebook.request("search", params); If Facebook answers with a response empty the application looks for with a greater distance of the center (the current position) params.putString("distance", "1000"); response = facebook.request("search", params); and if now find a place knows by Facebook, the application will publish the checkin in this page. To publish the checkin the application must request with the next code: Bundle params1 = new Bundle(); params1.putString("access_token", facebook.getAccessToken()); params1.putString("place", pageID); params1.putString("message", msgLocation.getText().toString()); JSONObject coordinates = new JSONObject(); coordinates.put("latitude", myLocOverlay.getMyLocation().getLatitudeE6() / 1E6); coordinates.put("longitude", myLocOverlay.getMyLocation().getLongitudeE6() / 1E6); params1.putString("coordinates",coordinates.toString()); response = facebook.request("me/checkins", params1, "POST"); 21
4.4 Google Maps Platform Our application has with a map to locate various user friends coordinates, for this we have used the classes provides by Google Maps API for Android, in the next points we will see the specials features used. To display Google Maps data is necessary register with Google Maps service and obtain a Maps API Key[Appendix Obtaining a Maps API Key] 4.4.1 Google Maps Activity The activity extends of MapActivity, this kind of activity is too an extension of Android activity so has all the methods and features necessary in order to our Android application works correctly. Is necessary this kind of activity to display a MapView, that we will see in the next section 4.3.2 this class is responsible for displaying a map. MapActivity responsibilities are activity lifecycle management and setup and teardown of services behind a MapView. 4.4.2 Class MapView MapView is the class that obtaining the data from Google Maps service displays a map. The map can be displayed in a number of modes, the application the default view. For the user can use the zoom controls the feature setBuiltInZoomControls is enabled. 4.4.3 User current location In this section we explain how the application locate the current location of the user, for this, is used the features of the class MyLocationOverlay, this overlay allows draw the user’s current location and accuracy on the map. The first step is link this overlay with the MapView on wich the location is to be overlayed. myLocOverlay = new MyLocationOverlay(this, mapView); To enable the user location, registering for updates from GPS provider or network provider, we use the method enableMyLocation() and for enable updates from the compass sensor we call the method enableCompass(). In addition, to draw the user location we add the new overlay to the MapView overlays. mapView.getOverlays().add(myLocOverlay); 22
4.4.4 User Friends Locations Once we have obtained the different coordinates of the user friends, the application will be able to draw them in the map. For this the software uses the class CustomizedItemizedOverlay that extends of ItemizedOverlay which consist of a list of OverlayItems. This handles sorting north-to-south for drawing, creating span bounds, drawing a marker for each point, and maintaining a focused item. The application creates an OverlayItem for each user, which has parameters such as a Geopoint, a title and a snippet. Where a Geopoint representing a pair of latitude and longitude, stored as integer numbers of microdegrees. Once created the user friend overlay the applications add it to the map. itemizedOverlay.addOverlay(overlayitem); mapOverlays.add(itemizedOverlay); 23
5 Results and discussion This section shows that results we have achieved and what were the problems encountered over the implementation and how we solved or how we could fix them. The Figure 7 shows how our application displays a Facebook dialog for the user can sign in with him Facebook account. The main problem in the application is the time spent in requests, the software must check all the user friends, and this time can be more different depending on the number of friends of the user. So, each time that the user launches the application he must wait too much time until all the friends locations are obtained, in the Section 7 we discuss possible solutions about this issue. The Figure 8 shows the average time with different number of user friends, to measure this time we have use the system method System.currentTimeMillis(), we measure the time when the application begins to request all the user friends information to check if they have or not checkins and the software will finish of measuring when the system has checked all the users, the difference between these two times will be measure five times for each number of user friends (10, 50, 100 and 200) and will obtain the average of these five measurements. 24
Time spent in checking User Friends information 350000 Time (miliseconds) 300000 315590 250000 200000 157741 Time (miliseconds) 150000 100000 76478,8 50000 0 13847,8 10 50 100 200 Number of User Friends Figure 8: Time spent in checking User Friends information. In addition, the time spent in requests can change depending of the channel performance, the application measure the time spent each time the locations are loaded or updated, it use this time to wait for the next information refresh to ensure that the last update is finished, we too use a flag to ensure if in any time the channel quality gets worse, and to refresh the information each more time if the internet connection is slow. Once the requests to obtain the friends locations have finished the friends are drawn in the map, this same shows the Figure 9 Figure 9: Friends draw in the map 25
When publishing the current user location we find a problem, in Facebook to publish a location is necessary publish a checkin that is associated with a Facebook Page, the problem is that if not exist a page with coordinates near the user location, the application does not be able to publish the checkin because Facebook Platform does not allow create page from its API. Then the application looks for a page near the user coordinates and publishes the checkin in this page. If the application does not find a page near will look for again but in a greater radio, if it does not find a page close to the current location shows a message indicating that it was not possible. 26
6 Conclusions The application has been developed completely implementing the requirements desired. These requirements are an application for a mobile device capable of obtain the locations of the Facebook friends of the user and use these locations to draw them in a Google Map, updating time to time the locations and enabling that the user can publish him current location in almost all cases. We have achieved fit the roles of Facebook, Google Maps and Android. On the other hand we have found various problems while develop the software such as the low performance caused by the amount of necessary requests to check that users has a current location (checkin), and the impossibility of create Facebook pages doing impossible publish checkins if not exists a Facebook page close to the current location of the mobile device. 27
7 Future work Finally, we discuss about the futures improvements to increase the functionality or enhance the performance. How we see in the Section 5 we find differents problems, we will try to propose solutions. On the other hand, we too propound new funcionalities that we think are interesting. 7.1 Enhancing the performance We find a low performance because the application must do a lot of requests to check if the user has checkins or not. How a future improvement would be enhance the performance for example storing the users with checkins in a physical file to in the next executions of the application, realize two different updates in parallel, the first would be update the locations of users with checkins stored in the file and the second check the rest of the users. This method ensures that the user can begin to interact with the application early. Also, having users with checkins on one side and the users without checkin in other, the system can realize two updates in parallel one for the user with checkins improving the sensation of real-time and other with the users without checkins, but that in sometime could publish one. 7.2 Publishing checkins Other problem that we find is the inability of creating Facebook page if there are not a place page close to the current location user when he wants to publish him location. We try to fix it doing a search in a greater radio but this method does not always work. As future work we propose create a efficient algorithm to obtain the nearest pages. As new functionality would be interesting that the user can choose the page where do the checkin because our application choose the first one. 7.3 Drawing the path As the application has a list of checkins which becomes a GPS trace, has coordinates and timestamps, would be interesting draw the path that any user follow while the application is working. Also, could be implemented the path from the current user location to any friend user located in the map. 28
Bibliography Google Inc. Android Developer Guide. Available in Web: Google Inc. Android Reference. Available in Web: Google Inc. Android SDK. Available in Web: Facebook. Facebook Developers Documentation. Available in Web: Facebook. Facebook SDK. Available in Web: Google Inc. Google Maps Reference for Android. Available in Web: Google Inc. Google Maps Dev Guide for Android. Available in Web: Steiniger, Stefan, Neun, Moritz, and Edwardes, Alistair. "Foundations of Location Based Services", University of Zurich. Available in Web: Schiller, J. H., and Voisard, A., 2004. “Location-based services”. Morgan Kaufmann Publishers. 29
Appendix A. Creating Facebook Application for Android Before you begin development with the Facebook Android SDK, you will need to install the Android SDK and dev tools, Git (the source control client we use for this SDK) and then clone the lastest version of the SDK from GitHub: Install Android SDK & the Eclipse Plugin Install Git Clone the GitHub repository: git clone git://github.com/facebook/facebook-android-sdk.git Once you have everything installed, open Eclipse and create a new Android Project (File | New | Project ...). We will use this project for the Facebook Android SDK source and then reference it from our app. As such, we need to get the content by selecting Create project from existing source and specifying the facebook directory from your git repository (~/facebook-android-sdk/facebook). With the SDK project created, we can create the app. Create a new Android Project (the Facebook SDK project will stay open in the Eclipse Workspace) from File | New | Project..., using the defaults and populating the require fields. 30
Once your app project is created, you will need to add a reference to the Facebook SDK project. You do this by opening the properties window for our app (File | Properties), selecting the Android item from the list, pressing the Add... button in the Library area and selecting the Facebook SDK project created above. 31
B. Registering Facebook Application We now need to export the signature for your app so that Facebook can use to ensure users are only communicating with your app on the Android. This is done by running the keytool. The following shows how to export the key for your app using the debug defaults specified by the Android SDK and Eclipse: keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 This tool generates a string that must be registered in the Mobile & Devices section of the Developer App for your app: 32
C. Obtaining Google Maps API Key To obtain Google Maps API Key you must follow the next steps: 1. Getting the MD5 Fingerprint, there are two possibilities: Getting it of your Signing Certificate keytool -list -alias alias_name -keystore my-release- key.keystore or of the SDK Debug Certificate $ keytool -list -alias androiddebugkey \ -keystore .keystore \ -storepass android -keypass android 2. Registering the Certificate Fingerprint with the Google Maps Service When you are ready to register for a Maps API Key, load this page in a browser: http://code.google. com/android/maps-api-signup.html To register for a Maps API Key, follow these steps: 1. If you don't have a Google account, use the link on the page to set one up. 2. Read the Android Maps API Terms of Service carefully. If you agree to the terms, indicate so using the checkbox on the screen. 3. Paste the MD5 certificate fingerprint of the certificate that you are registering into the appropriate form field. 4. Click "Generate API Key" 3. Adding the Maps API Key to your Application Once you've registered with the Google Maps service and have obtained a Maps API Key, you must add it to your application's MapView objects, so that the Maps server will allow them to download Maps tiles. For elements declared in XML layout files, add the Maps API Key as the value of a special attribute — android:apiKey. For example: 33
You can also read