{"id":210162,"date":"2014-01-24T11:50:04","date_gmt":"2014-01-24T07:50:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=210162"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=210162","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u043c\u0438 (geofences) \u0432 Android<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/940\/62f\/810\/94062f810bd18682c870f53341618235.png\" align=\"left\"\/><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e <a href=\"https:\/\/developer.android.com\/google\/play-services\/location.html\">Location APIs<\/a> \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u043e \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u0445 (geofences) \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 Google I\/0 2013 (<a href=\"http:\/\/www.youtube.com\/watch?v=Bte_GHuxUGc\">\u0432\u0438\u0434\u0435\u043e<\/a> \u0438 <a href=\"http:\/\/commondatastorage.googleapis.com\/io-2013\/presentations\/106 - Beyond the Blue Dot- New features in Android Location (1).pdf\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a>). \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434, \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435\u0442 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c (\u0442\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/191290\/\">\u043e\u0434\u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435<\/a>). \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Location APIs?<\/h4>\n<p>  Location APIs \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Google Play \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 <a href=\"http:\/\/developer.android.com\/reference\/android\/location\/LocationManager.html\">LocationManager<\/a>, \u0434\u0430\u043d\u043d\u044b\u0435 API \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u043c \u044d\u043d\u0435\u0440\u0433\u043e\u0441\u0431\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435\u043c. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u043c\u0438 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435\u043c \u044d\u043d\u0435\u0440\u0433\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u043c \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430: \u0435\u0434\u0435\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435, \u0435\u0434\u0435\u0442 \u043d\u0430 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0435, \u0438\u0434\u0435\u0442 \u043f\u0435\u0448\u043a\u043e\u043c \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0443 \u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u043c\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u043e\u043d\u0443, \u043f\u043e\u043a\u0438\u0434\u0430\u0435\u0442 \u0435\u0451 \u043b\u0438\u0431\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0437\u043e\u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <br \/>  \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 <a href=\"http:\/\/developer.android.com\/shareables\/training\/GeofenceDetection.zip\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/a> \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u0439. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0451\u043c:  <\/p>\n<ul>\n<li>\u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Location APIs<\/li>\n<li>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c<\/li>\n<li>\u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438<\/li>\n<\/ul>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u044e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u0445 \u0438 \u043e\u043f\u0443\u0449\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: Google Play \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434 \u0438\u0445 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c. \u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u043e \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/developer.android.com\/reference\/com\/google\/android\/gms\/common\/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context)\">GooglePlayServicesUtil.isGooglePlayServicesAvailable<\/a> \u0438 \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0430<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0440\u0430\u0434\u0438\u0443\u0441 \u0433\u0435\u043e\u0437\u043e\u043d\u044b. \u041f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435\/\u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u043d\u0435\u0451 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0441 id \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u0438 \u0442\u0438\u043f\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u043c\u044b \u0435\u0451 \u0443\u0434\u0430\u043b\u0438\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0434\u043b\u044f \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\"><a href=\"https:\/\/github.com\/Ne4istb\/AndroidGeofenceTest\">github<\/a><\/div>\n<\/div>\n<h4>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/h4>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<ol>\n<li>\u0418\u0437 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0433\u0435\u043e\u0437\u043e\u043d\u0435.<\/li>\n<li>\u0421\u0435\u0440\u0432\u0438\u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <b>LocationClient<\/b>.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 <b>LocationClient <\/b>\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0433\u0435\u043e\u0437\u043e\u043d\u044b (<b>Geofence<\/b>) \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u043c <i>PendingIntent<\/i>.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043e\u0442 <b>LocationClient <\/b>\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441.<\/li>\n<li>\u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u044f \u043d\u0430\u0434\u0435\u0436\u0434\u0430 \u043d\u0430 <i>PendingIntent<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 <i>IntentService <\/i>\u043f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u0432 \u0437\u043e\u043d\u0443 \u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0437\u043e\u043d\u044b. \u0421\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0440 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0433\u0435\u043e\u0437\u043e\u043d.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043d\u043e\u0432\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <b>LocationClient<\/b>.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 <b>LocationClient <\/b>\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0433\u0435\u043e\u0437\u043e\u043d\u044b.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u0443\u0434\u0430\u043b\u0435\u043d\u044b, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043e\u0442 <b>LocationClient <\/b>\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441.<\/li>\n<li>Profit!<\/li>\n<\/ol>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043b\u0438\u0446\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <b>LocationClient<\/b>. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a API \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u043c\u0438.<\/p>\n<h4>\u041a \u0434\u0435\u043b\u0443!<\/h4>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c Google Play \u0441\u0435\u0440\u0432\u0438\u0441\u044b. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"http:\/\/developer.android.com\/google\/play-services\/setup.html\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  \u0414\u0430\u043b\u0435\u0435 \u0432 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0418\u0437 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443:<\/p>\n<pre><code class=\"java\">\tint transitionType = Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT;  \tMyGeofence myGeofence = new MyGeofence(mId, latitude, longitude, radius, transitionType);  \tIntent geofencingService = new Intent(activity, GeofencingService.class);  \tgeofencingService.putExtra(GeofencingService.EXTRA_ACTION, GeofencingService.Action.ADD); \tgeofencingService.putExtra(GeofencingService.EXTRA_GEOFENCE, myGeofence);  \tactivity.startService(geofencingService); <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c <i>Intent <\/i>\u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (<i>GeofencingService<\/i>) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0430\u043a \u043a\u0430\u043a <i>GeofencingService <\/i>\u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0433\u0435\u043e\u0437\u043e\u043d (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b), \u0442\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (<i>GeofencingService.Action.ADD<\/i>). \u0422\u0430\u043a\u0436\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u043d\u0443\u0436\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0433\u0435\u043e\u0437\u043e\u043d\u0435. \u0418\u0445 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 MyGeofence, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 <b>Geofence.Builder <\/b>(\u043e \u043d\u0451\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435). <br \/>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0446\u0435\u043d\u0442\u0440\u0430 \u0438 \u0440\u0430\u0434\u0438\u0443\u0441 \u0437\u043e\u043d\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0440\u0435\u0445 \u0432\u0438\u0434\u043e\u0432: GEOFENCE_TRANSITION_ENTER, GEOFENCE_TRANSITION_EXIT \u0438 GEOFENCE_TRANSITION_DWELL. \u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u043a \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0440\u0430\u0437\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f. GEOFENCE_TRANSITION_DWELL \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u043e\u0448\u0435\u043b \u0432 \u0437\u043e\u043d\u0443 \u0438 \u043f\u0440\u043e\u0431\u044b\u043b \u0432 \u043d\u0435\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0438\u0433\u043d\u0430\u043b, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <i>setLoiteringDelay <\/i>\u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0433\u0435\u043e\u0437\u043e\u043d\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 GEOFENCE_TRANSITION_DWELL \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443. \u0421\u0435\u0440\u0432\u0438\u0441 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 <b>GooglePlayServicesClient.ConnectionCallbacks<\/b>, <b>GooglePlayServicesClient.OnConnectionFailedListener<\/b>, <b>LocationClient.OnAddGeofencesResultListener<\/b>, <b>LocationClient.OnRemoveGeofencesResultListener<\/b> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <b>LocationClient<\/b>.<br \/>  \u0412 <i>onStartCommand <\/i>\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (ADD \u0438\u043b\u0438 REMOVE) \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <b>LocationClient<\/b>:<\/p>\n<pre><code class=\"java\">\tmAction = (Action) intent.getSerializableExtra(EXTRA_ACTION);  \tswitch (mAction) { \t\tcase ADD: \t\t\tMyGeofence newGeofence = (MyGeofence) intent.getSerializableExtra(EXTRA_GEOFENCE); \t\t\tmGeofenceListsToAdd.add(newGeofence.toGeofence()); \t\t\tbreak; \t\tcase REMOVE: \t\t\tmGeofenceListsToRemove = Arrays.asList(intent.getStringArrayExtra(EXTRA_REQUEST_IDS)); \t\t\tbreak;         }  \tmLocationClient = new LocationClient(this, this, this);         mLocationClient.connect(); <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0433\u0435\u043e\u0437\u043e\u043d\u0443 <i>mGeofenceListsToAdd<\/i>, \u043c\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <i>toGeofence()<\/i> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <i>MyGeofence<\/i>. \u042f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u0447\u0442\u043e <i>MyGeofence <\/i>\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 <b>Geofence.Builder<\/b>:<\/p>\n<pre><code class=\"java\">    public MyGeofence(int id, double latitude, double longitude, float radius, int transitionType) {         this.id = id;         this.latitude = latitude;         this.longitude = longitude;         this.radius = radius;         this.transitionType = transitionType;     }      public Geofence toGeofence() {         return new Geofence.Builder()                 .setRequestId(String.valueOf(id))                 .setTransitionTypes(transitionType)                 .setCircularRegion(latitude, longitude, radius)                 .setExpirationDuration(ONE_MINUTE)                 .build();     } <\/code><\/pre>\n<p>  <b>Geofence.Builder<\/b> \u2014 \u044d\u0442\u043e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <b>Geofence<\/b>. \u041c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434<i> build()<\/i> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0412\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <i>setExpirationDuration<\/i>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0434\u0432\u0443\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445: \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043f\u0440\u0438 \u044f\u0432\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 NEVER_EXPIRE, \u0442\u043e \u0432\u044b \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0431 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f <b>Location APIs<\/b> \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 100 \u0433\u0435\u043e\u0437\u043e\u043d \u043d\u0430 \u043e\u0434\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a <b>LocationClient <\/b>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f, \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <i>onConnected <\/i>\u043a\u043e\u043b\u0431\u044d\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <b>GooglePlayServicesClient.ConnectionCallbacks<\/b>. \u0412 \u043d\u0435\u043c \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u0431\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<pre><code class=\"java\">    @Override     public void onConnected(Bundle bundle) {         Log.d(&quot;GEO&quot;, &quot;Location client connected&quot;);          switch (mAction) {             case ADD:                 Log.d(&quot;GEO&quot;, &quot;Location client adds geofence&quot;);                 mLocationClient.addGeofences(mGeofenceListsToAdd, getPendingIntent(), this);                 break;             case REMOVE:                 Log.d(&quot;GEO&quot;, &quot;Location client removes geofence&quot;);                 mLocationClient.removeGeofences(mGeofenceListsToRemove, this);                 break;         }     } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, <b>addGeofences <\/b>\u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <i>PendingIntent<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <i>PendingIntent <\/i>\u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c <i>IntentService<\/i>:<\/p>\n<pre><code class=\"java\">    private PendingIntent getPendingIntent() {         Intent transitionService = new Intent(this, ReceiveTransitionsIntentService.class);         return PendingIntent.getService(this, 0, transitionService, PendingIntent.FLAG_UPDATE_CURRENT);     } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0443 \u043d\u0430\u0441 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 <b>OnAddGeofencesResultListener <\/b>\u0438\u043b\u0438 <b>onRemoveGeofencesByRequestIdsResult <\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043e\u0442 <b>LocationClient <\/b>\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<pre><code class=\"java\">    @Override     public void onAddGeofencesResult(int i, String[] strings) {         if (LocationStatusCodes.SUCCESS == i) {              Log.d(&quot;GEO&quot;, &quot;Geofences added &quot; + strings);              for (String geofenceId : strings)                 Toast.makeText(this, &quot;Geofences added: &quot; + geofenceId, Toast.LENGTH_SHORT).show();              mLocationClient.disconnect();             stopSelf();         } else {             Log.e(&quot;GEO&quot;, &quot;Error while adding geofence: &quot; + strings);         }     }      @Override     public void onRemoveGeofencesByRequestIdsResult(int i, String[] strings) {         if (LocationStatusCodes.SUCCESS == i) {             Log.d(&quot;GEO&quot;, &quot;Geofences removed&quot; + strings);             mLocationClient.disconnect();             stopSelf();         } else {             Log.e(&quot;GEO&quot;, &quot;Error while removing geofence: &quot; + strings);         }     } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2013 \u044d\u0442\u043e <i>IntentService<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u0412\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 <i>onHandleIntent<\/i>:<\/p>\n<pre><code class=\"java\">    @Override     protected void onHandleIntent(Intent intent) {          if (LocationClient.hasError(intent)) {             Log.e(TRANSITION_INTENT_SERVICE, &quot;Location Services error: &quot; + LocationClient.getErrorCode(intent));             return;         }          int transitionType = LocationClient.getGeofenceTransition(intent);          List&lt;Geofence&gt; triggeredGeofences = LocationClient.getTriggeringGeofences(intent);         List&lt;String&gt; triggeredIds = new ArrayList&lt;String&gt;();          for (Geofence geofence : triggeredGeofences) {             Log.d(&quot;GEO&quot;, &quot;onHandle:&quot; + geofence.getRequestId());             processGeofence(geofence, transitionType);             triggeredIds.add(geofence.getRequestId());         }          if (transitionType == Geofence.GEOFENCE_TRANSITION_EXIT)             removeGeofences(triggeredIds);     } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u044e\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <b>LocationClient<\/b>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <i>hasError<\/i>. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0445 \u0433\u0435\u043e\u0437\u043e\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <i>getGeofenceTransition <\/i>\u0438 <i>getTriggeringGeofences <\/i>\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0435\u0451 id. \u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0433\u0435\u043e\u0437\u043e\u043d\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u0438\u0437 \u0433\u0435\u043e\u0437\u043e\u043d\u044b. <br \/>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0433\u0435\u043e\u0437\u043e\u043d \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0435\u0440\u0432\u0438\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (REMOVE) \u0438 \u0441\u043f\u0438\u0441\u043e\u043a id \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"java\">    private void removeGeofences(List&lt;String&gt; requestIds) {         Intent intent = new Intent(getApplicationContext(), GeofencingService.class);          String[] ids = new String[0];         intent.putExtra(GeofencingService.EXTRA_REQUEST_IDS, requestIds.toArray(ids));         intent.putExtra(GeofencingService.EXTRA_ACTION, GeofencingService.Action.REMOVE);          startService(intent);     } <\/code><\/pre>\n<h4>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451! <\/h4>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c. \u0416\u0435\u043b\u0430\u044e \u0432\u0441\u0435\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439! \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/210162\/\"> http:\/\/habrahabr.ru\/post\/210162\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/940\/62f\/810\/94062f810bd18682c870f53341618235.png\" align=\"left\"\/><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e <a href=\"https:\/\/developer.android.com\/google\/play-services\/location.html\">Location APIs<\/a> \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u043e \u0433\u0435\u043e\u0437\u043e\u043d\u0430\u0445 (geofences) \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 Google I\/0 2013 (<a href=\"http:\/\/www.youtube.com\/watch?v=Bte_GHuxUGc\">\u0432\u0438\u0434\u0435\u043e<\/a> \u0438 <a href=\"http:\/\/commondatastorage.googleapis.com\/io-2013\/presentations\/106 - Beyond the Blue Dot- New features in Android Location (1).pdf\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a>). \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434, \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435\u0442 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c (\u0442\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/191290\/\">\u043e\u0434\u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435<\/a>). \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-210162","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/210162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=210162"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/210162\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=210162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=210162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=210162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}