Más contenido relacionado
Similar a Making Your Apps More Sociable (20)
Making Your Apps More Sociable
- 1. Making your
apps more sociable
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
- 2. Contents
Map & Locations features
– Map control
– Location provider
– Remote landmark store
Social features
– Buddy
– SNS gateway
*This material is based on bada SDK 1.0.0b3
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 2
- 3. Map in bada
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 3
- 4. Think of this …
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 4
- 5. To do this, you need to …
Display a map
– Map control
Get my current location
– Location provider
Store information which has a location
– Database
– Landmark store (Device & Remote )
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 5
- 6. Location application essentials
Features Header Library Priv. group Priv. level
Map Control FlocationControls LOCATION_SERVICE NORMAL
Location Provider FLocations.h LOCATION NORMAL
Remote Landmark FLocations
REMOTE_LANDMARK SYSTEM
Store
You must set the privilege group:
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 6
- 7. Map in bada
1. Map control
2. Location provider
3. Remote landmark store
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 7
- 8. Getting a deCarta key
http://developer.decarta.com GO!
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 8
- 9. Using the map control (1/4)
Step 1: Set the map key for deCarta:
String extraInfo =
L"ClientName=( );ClientPassword=( );HostUrl=http://
ws.decarta.com/openls/openls";
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 9
- 10. Using the map control (2/4)
Step 1: Set the map key for deCarta:
String extraInfo =
L"ClientName=( );ClientPassword=( );HostUrl=http://
ws.decarta.com/openls/openls";
Step 2: Create a map provider:
IMapServiceProvider* __pMapProvider;
__pMapProvider = static_cast<IMapServiceProvider*>(
ProviderManager::ConnectToServiceProviderN
(L"deCarta",LOC_SVC_PROVIDER_TYPE_MAP, extraInfo));
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 10
- 11. Using the map control (3/4)
Step 1: Set the map key for deCarta
Step 2: Create a map provider
Step 3: Construct the map control:
__pMap = new Map();
__pMap->Construct(Rectangle(/*size*/), *__pMapProvider);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 11
- 12. Using the map control (4/4)
Step 1: Set the map key for deCarta
Step 2: Create a map provider
Step 3: Construct the map control:
__pMap = new Map();
__pMap->Construct(Rectangle(/*size*/), *__pMapProvider);
Step 4: Set the map control :
__pMap->SetCenter(/* latitude, longitude */, false);
__pMap->SetPanEnabled(true);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 12
- 13. When maps are not displayed
Check that the name and
password are valid
Check the proxy if you are
in a proxy environment
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 13
- 14. Setting proxies
Run the simulator:
Menu > Settings > Connectivity >
Network > Connection > bada
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 14
- 15. Location in bada
1. Map control
2. Location provider
3. Remote Landmark Store
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 15
- 16. Getting the position from the GPS
Step 1: Add a location update listener:
__pLocProvider = new LocationProvider();
__pLocProvider->Construct(LOC_METHOD_GPS);
__pLocProvider->RequestLocationUpdates
(/*ILocationListener &*/, 5, false);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 16
- 17. Getting the position from the GPS
Step 1: Add a location update listener:
__pLocProvider = new LocationProvider();
__pLocProvider->Construct(LOC_METHOD_GPS);
__pLocProvider->RequestLocationUpdates
(/*ILocationListener &*/, 5, false);
Step 2: Get the position in the listener:
void MyClass::OnLocationUpdated(Location &loc)
{
const QualifiedCoordinates* pCoord =
loc.GetQualifiedCoordinates();
if (null != pCoord)
__pMap->SetCenter(*pCoord, true);
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 17
- 18. Location in bada
1. Map control
2. Location provider
3. Remote landmark store
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 18
- 19. Landmarks
A landmark is a location that has a name
In bada, Landmark consists of:
Data structures
Name
Description
Coordinates
…
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 19
- 20. Landmark stores
A landmark store is a persistent database for
landmarks
Landmarks can be stored on the device or on
the bada Server
Remote landmark stores can be shared among
bada users
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 20
- 21. Accessing bada Server
You need a bada account to store landmarks on
bada Server
Samsung bada provides an easier way for sign
up and sign in:
– AppControl
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 21
- 22. AppControl
AppControl is used to start an application and
control specific behavior in it
APPCONTROL_CALENDAR APPCONTROL_DIAL APPCONTROL_MEDIA
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 22
- 23. Signing in the bada Server
AppControl* pAc =
AppManager::FindAppControlN
(APPCONTROL_SIGNIN, OPERATION_SIGNIN);
if(null != pAc) {
pAc->Start(null, this);
delete pAc;
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 23
- 24. Adding landmarks to a LandmarkStore
Step 1: Create a landmark:
Landmark* pLandmark = new Landmark();
pLandmark->SetQualifiedCoordinates(/* QualfiedCoor */);
pLandmark->SetName(/*name*/);
pLandmark->SetDescription(/*description*/);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 24
- 25. Adding landmarks to a LandmarkStore
Step 1: Create a landmark:
Landmark* pLandmark = new Landmark();
pLandmark->SetQualifiedCoordinates(/* QualfiedCoor */);
pLandmark->SetName(/*name*/);
pLandmark->SetDescription(/*description*/);
Step 2: Add a landmark to a RemoteLandmarkStore:
__pServerStore = new RemoteLandmarkStore
(/*STORE NAME*/, /*IRemoteLandmarkStoreListener&*/);
__pServerStore->AddLandmark(*pLandmark, /*category*/, reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 25
- 26. Searching for landmarks (1/2)
Step 1: Request a search:
void MyApp::OnMapDrawCompleted(const Map& source)
{
RectangleGeographicArea area= source.GetViewport();
LandmarkFilter filter;
filter.SetGeographicAreaFilter(&area);
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 26
- 27. Searching for landmarks (1/2)
Step 1: Request a search:
void MyApp::OnMapDrawCompleted(const Map& source)
{
RectangleGeographicArea area= source.GetViewport();
LandmarkFilter filter;
filter.SetGeographicAreaFilter(&area);
LandmarkPropertySelector selector;
selector.SetQualifiedCoordinatesSelector(true);
selector.SetDescriptionSelector(true);
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 27
- 28. Searching for landmarks (1/2)
Step 1: Request a search:
void MyApp::OnMapDrawCompleted(const Map& source)
{
RectangleGeographicArea area= source.GetViewport();
LandmarkFilter filter;
filter.SetGeographicAreaFilter(&area);
LandmarkPropertySelector selector;
selector.SetQualifiedCoordinatesSelector(true);
selector.SetDescriptionSelector(true);
RequestId reqId;
__pServerStore->SearchLandmarks
(&filter, &selector, null,
SORT_ORDER_ASCENDING, SORT_BY_NAME, reqId);
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 28
- 29. Searching for landmarks (2/2)
Step 1: Request a search
Step 2: Get results:
void MyApp::OnLandmarksReceivedN(…, IList* pResults, …)
{
// implement this handler
}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 29
- 30. Landmark Manager Demo:
Demo sequence:
– Display a map
– Search the nearby landmark
– Display the landmark information
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 30
- 31. More features for locations
Module Major Uses
Remote location Send a location to bada Server
provider Get other people’s (last known) position
Trace service Get other people’s trajectories
Map service Get a map
Directory service Search through landmarks from a service provider
Geocoding service Perform geocoding and reverse-geocoding
Route service Get a routing information from starting point to end point
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 31
- 32. When Location meets social features …
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 32
- 33. Using buddy features
Request, respond to, and delete buddies
Manage groups and friendship levels within your
buddies
Share your location, contents, or profile with
buddies
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 33
- 34. Social in bada
1. Searching profile
2. Becoming buddies
3. Sharing locations
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 34
- 35. Searching profile
1. Set profile exposure level
2. Search Mike’s profile
bada Server
3.Send 4. Respond to
buddy request buddy request
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 35
- 36. Mike: Set profile exposure level
I want to share
my location
Step 1: Create a PrivacyManager:
__privacyManager = new PrivacyManager();
__privacyManager->Construct
(IPrivacyManagerListener&);
36
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
- 37. Mike: Set profile exposure level
Set my profile
searchable
Step 1: Create a PrivacyManager:
__privacyManager = new PrivacyManager();
__privacyManager->Construct
(IPrivacyManagerListener&);
Step 2: Set the ProfileExposureLevel:
__privacyManager->SetProfileExposureLevel
(PROFILE_SEARCHABLE, reqId);
37
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
- 38. Mike: Set profile exposure level
Is the set
request
Step 1: Create a PrivacyManager: successful?
__privacyManager = new PrivacyManager();
__privacyManager->Construct
(IPrivacyManagerListener&);
Step 2: Set the ProfileExposureLevel:
__privacyManager->SetProfileExposureLevel
(PROFILE_SEARCHABLE, reqId);
Step 3: Confirm the result:
void OnProfileExposureLevelUpdated(){…}
! You must sign-in with bada account before using PrivacyManager
38
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
- 39. Jane: Search profile I want to find
some friends
on bada
Step 1: Construct a ProfileService:
__pProfileService = new ProfileService();
__pProfileService->Construct
(IProfileServiceListener&);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 39
- 40. Jane: Search profile Let me try
Mike
Step 1: Construct a ProfileService:
__pProfileService = new ProfileService();
__pProfileService->Construct
(IProfileServiceListener&);
Step 2: Search profiles:
__pProfileService->SearchProfilesByName(L”Mike”, …);
– Search by Email, LoginId, Name, PhoneNumber
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 40
- 41. Jane: Search profile Can I check
the results?
Step 1: Construct a ProfileService:
__pProfileService = new ProfileService();
__pProfileService->Construct
(IProfileServiceListener&);
Step 2: Search profiles:
__pProfileService->SearchProfilesByName(L”Mike”, …);
– Search by Email, LoginId, Name, PhoneNumber
Step 3: Receive profiles:
void OnProfileSearchResultsReceivedN(…,
Osp::Base::Collection::IList* pBasicProfileList,…)
{…}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 41
- 42. Social
1. Searching profile
2. Becoming buddies
3. Sharing locations
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 42
- 43. Becoming buddies
1. Set profile exposure level
2. Search Mike’s profile
bada Server
3. Send a
4. Respond to buddy request
buddy request
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 43
- 44. Jane: Send a buddy request
How can I
send the
request to
Step 1: Create a BuddyService: Mike
__pBuddyService = new BuddyService();
__pBuddyService->Construct
(IBuddyServiceListener &);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 44
- 45. Jane: Send a buddy request
Send the
request
Step 1: Create a BuddyService:
__pBuddyService = new BuddyService();
__pBuddyService->Construct
(IBuddyServiceListener &);
Step 2: Send a buddy request:
__pBuddyService->RequestBuddy
(/* Mikes’s UserID */, reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 45
- 46. Jane: Send a buddy request
And I can
confirm the
results
Step 1: Create a BuddyService:
__pBuddyService = new BuddyService();
__pBuddyService->Construct
(IBuddyServiceListener &);
Step 2: Send a buddy request:
__pBuddyService->RequestBuddy
(/* Mikes’s UserID */, reqId);
Step 3: Confirm results:
void OnBuddyRequestSent(…)
{…}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 46
- 47. Mike: Respond to a buddy request
Is there any
buddy
Step 1: Get buddy requests: request I
received?
__pBuddyService->GetReceivedBuddyRequests(reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 47
- 48. Mike: Respond to a buddy request
Get the
request
Step 1: Get buddy requests: from the
server
__pBuddyService->GetReceivedBuddyRequests(reqId);
Step 2: Receive buddy requests:
void OnReceivedBuddyRequestsReceivedN
(…,IList*pRequestList ,…)
{…}
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 48
- 49. Mike: Respond to a buddy request
Got Jane’s,
Step 1: Get buddy requests: Ok accept!
__pBuddyService->GetReceivedBuddyRequests(reqId);
Step 2: Receive buddy requests:
void OnReceivedBuddyRequestsReceivedN
(…,IList*pRequestList ,…)
{…}
Step 3: Respond to buddy requests:
__pBuddyService->RespondToBuddyRequest
(*pRequest, RESPONSE_ACCEPT , reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 49
- 50. Social
1. Searching profile
2. Becoming buddies
3. Sharing locations
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 50
- 51. Sharing locations
bada Server
2. Search
1. Share
Mike’s location
Mike’s location
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 51
- 52. Mike: Share a location
Can I share
my location
to my
friends?
Step 1: Set access control list for location:
__privacyManager->SetUserInfoPrivacy
(INFO_LOCATION , ACCESS_BUDDY , reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 52
- 53. Mike: Share a location Get my
current
location
Step 1: Set access control list for location:
__privacyManager->SetUserInfoPrivacy
(INFO_LOCATION , ACCESS_BUDDY , reqId);
Step 2: Get Mike’s location:
__pLocationProvider->RequestLocationUpdates(…);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 53
- 54. Mike: Share a location Send my
location to
the server
Step 1: Set access control list for location:
__privacyManager->SetUserInfoPrivacy
(INFO_LOCATION , ACCESS_BUDDY , reqId);
Step 2: Get Mike’s location:
__pLocationProvider->RequestLocationUpdates(…);
Step 3: Register Mike’s location to bada Server:
RemoteLocationProvider::StartLocationReport(…);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 54
- 55. MyPlace Demo:
Demo sequence:
– Display a map
– Get my friends location
– Display them on the map
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 55
- 56. The SNS Gateway
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 56
- 57. SNS gateway
The SNS gateway has unified APIs for different
SNS providers
Check the SNS provider’s features and
properties before using the SNS gateway:
Property Description Twitter Facebook
First Name The person’s given name.
Last Name The person’s family name.
Display Name The person’s display name.
User Name The person’s user name.
* MySpace will be supported in SDK b2
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 57
- 58. SNS gateway
Mike Jane
1. Sharing
2. Show my and Jane’s locations my position
bada
Server
3. Set my status
4. Get friend status
SNS Server Alice
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 58
- 59. Authentication
Step 1: Create SNS gateway
__pSnsGateway = new SnsGateway();
__pSnsGateway->Construct
(ISnsGatewayListener&, ISnsContentListener *,
ISnsPeopleListener *, ISnsActivityListener *);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 59
- 60. Authentication
Step 1: Create SNS gateway
__pSnsGateway = new SnsGateway();
__pSnsGateway->Construct
(ISnsGatewayListener&, ISnsContentListener *,
ISnsPeopleListener *, ISnsActivityListener *);
Step 2: Login to SNS account using SNS
gateway API
__pAuthenticator = new SnsAuthenticator();
__pAuthenticator->Construct(ISnsAuthenticatorListener & );
__pAuthenticator->Authenticate
(L"twitter", /*Key*/, /*Secret*/);
…
__pSnsGateway->AddAuthResult(authResult);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 60
- 61. Updating and getting status
Update user status:
__pSnsGateway->UpdateMyStatusText
(L”twitter”, L”Let’s meet at Starbucks”, reqId);
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 61
- 62. Updating and getting status
Update user status:
__pSnsGateway->UpdateMyStatusText
(L”twitter”, L”Let’s meet at Starbucks”, reqId);
Get friend’s status :
__pSnsGateway->GetStatusText
(L"twitter", L”Mike”, reqId);
…
void OnSnsStatusTextReceived
(..., SnsStatusText *pStatusText, ...)
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 62
- 63. SimpleTwitter Demo:
Demo sequence:
– Sing-in with the bada account
– Authenticate with the Twitter server
– Update tweets
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 63
- 64. More social features
Manage personal data on the device and server
Share and interact with other users
Device Features Server-assisted Features
•Buddy •Profile •Board
•Address •Calendar •Lifelog
Book Book
23 •Messaging •SNS Gateway
IM
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 64
- 65. Social application essentials
Features Header Library Priv. Group Priv. Level
PrivacyManager PRIVACY_SERVICE SYSTEM
ProfileService PROFILE_SERVICE SYSTEM
FSocial.h FSocialServices
BuddyService BUDDY_SERVICE SYSTEM
SnsGateway SNS_SERVICE SYSTEM
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 65
- 66. Summary
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 66
- 67. What we have learned
Locations:
– How to use the Map control
– How to get a location
– How to use a remote landmark store
– How to get other people’s locations
Social:
– How to get buddy
– How to use the SNS Gateway
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 67
- 68. Find out more: Locations
Tutorial:
– bada Tutorial.Location.pdf
Samples:
– LandmarkManager
– LocationManager
– MapControl
– MapViewer
– Navigator
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 68
- 69. Find out more: Social
Tutorial:
– bada Tutorial.Social.pdf
Samples:
– BuddyManager
– PrivacyManager
– SimpleTwitter
– TwitterOAuth
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved. 69
- 70. Dive into
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.