{"id":165251,"date":"2013-01-09T19:59:03","date_gmt":"2013-01-09T15:59:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=165251"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=165251","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Android \u0434\u043b\u044f web \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0438\u043b\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e!<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u043e\u0439 \u043c\u043d\u043e\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/165105\/\">\u0447\u0430\u0441\u0442\u0438 1<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435 <\/h4>\n<p>  <b>\u0412\u0430\u0436\u043d\u043e<\/b>: \u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0440\u043e\u043a \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c. \u0410\u0432\u0442\u043e\u0440 \u0443\u0440\u043e\u043a\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u043c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b Android. \u042f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u043d\u043e\u0448\u0443 \u0441\u0432\u043e\u0438 \u0438\u0437\u0432\u0438\u043d\u0435\u043d\u0438\u044f, \u0437\u0430 \u043d\u0435\u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<h4>RegistrationActivity<\/h4>\n<p>  \u0412 Activity \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<a name=\"habracut\"><\/a>  <\/p>\n<ul>\n<li>1. \u041f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b <\/li>\n<li>2. Validation \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0438 \u043c\u043d\u043e\u0439 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e) <\/li>\n<li>3. \u0417\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 <\/li>\n<li>4. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/li>\n<\/ul>\n<p>  \u0427\u0442\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e \u0438 \u043e\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0439 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e:<\/p>\n<pre><code class=\"java\">final EditText login = (EditText)findViewById(R.id.login); final EditText password = (EditText)findViewById(R.id.password); final EditText password2 = (EditText)findViewById(R.id.password2); \/\/ \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u0438 <\/code><\/pre>\n<h4>\u0420\u0430\u0431\u043e\u0442 \u0441 \u0441\u0435\u0442\u044c\u044e \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/developer.android.com\/reference\/android\/os\/AsyncTask.html\">AsyncTask <\/a> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a:<\/p>\n<pre><code class=\"java\">\/\/ 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u044d\u0442\u043e \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u043c doInBackground, \u0435\u0433\u043e \u044f \u0431\u0443\u0434\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432 onPostExecute class AsyncTaskExample extends AsyncTask&lt;Void, Integer, String&gt; { \t\t\t\t\t                     \/\/ \u0444\u043e\u043d\u043e\u0432\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \t\t\t\t\t@Override \t\t\t\t\tprotected String doInBackground(Void... params) { \t\t\t\t\t\t \t\t\t\t\t}                     \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 doInBackground, \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a UI \t\t\t\t\tprotected void onPostExecute(String result) {  \t\t\t\t\t\t} catch (JSONException e) { \t\t\t\t\t\t\t \t\t\t\t\t\t\te.printStackTrace(); \t\t\t\t\t\t} \t\t\t\t\t\t \t\t\t\t\t\t \t\t\t        }  } \t\t\t\t\/\/ \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u043e\u0442\u043e\u043a\u0430 \t\t\t\tnew AsyncTaskExample().execute(); <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u044f \u0432\u044b\u043d\u0435\u0441 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 (\u043a\u043b\u0430\u0441\u0441\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0430\u043a\u0435 \u0447\u0442\u043e \u0438 Activity). \u041c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043d, \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">public class ServerSendData {  \tprivate static String server = &quot;http:\/\/xxx.xxx.x.xxx\/&quot;; \tpublic static String mlogin = null; \tpublic static String mpassword = null;  \tpublic static String sendRegData(String login,String password) {  \t\tString result = null; \t\tmlogin = login; \t\tmpassword = password;  \t\ttry { \t\t\tURL url = new URL(&quot;&quot; + server + &quot;apiregistration\/create\/&quot;+mlogin+&quot;\/&quot;+mpassword+&quot;&quot;); \t\t\t \t\t\tURLConnection connection = url.openConnection(); \t\t\tHttpURLConnection httpConnection = (HttpURLConnection)connection;  \t\t\tint responseCode = httpConnection.getResponseCode();  \t\t\tif (responseCode == HttpURLConnection.HTTP_OK) { \t\t\t\tInputStream in = httpConnection.getInputStream(); \t\t\t\tBufferedReader r = new BufferedReader(new InputStreamReader(in));                                  \t\t\t\tresult = r.readLine();  \t\t\t\tLog.w(&quot;res&quot;,&quot;&quot;+result+&quot;&quot;);   \t\t\t} else \t\t\t{ \t\t\t\t \t\t\t}   \t\t}  \t\tcatch (MalformedURLException e) {} \t\tcatch (IOException e1) {}  \t\treturn result; \t} <\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 JSON. \u041e\u0442\u0432\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>{&quot;status&quot;:&quot;login_busy&quot;} <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u0435\u043b\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0438. \u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 doInBackground:<\/p>\n<pre><code class=\"java\">return ServerSendData.sendRegData(&quot;&quot;+login.getText().toString()+&quot;&quot;,&quot;&quot;+ password.getText().toString()+&quot;&quot;); <\/code><\/pre>\n<p>  \u0412 onPostExecute \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c: <\/p>\n<pre><code class=\"java\">JSONObject object = new JSONObject(result); String status = object.getString(&quot;status&quot;); \/\/ status \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c login_busy <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u043e\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0432\u0430\u0448\u0438\u0445 \u043d\u0435\u0440\u0432\u043d\u044b\u0445 \u043a\u043b\u0435\u0442\u043e\u043a, \u044f \u043e\u0441\u043c\u0435\u043b\u044e\u0441\u044c \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043e\u043f\u0440\u043e\u0441.    \t \t\t \t\t\t \t<\/p>\n<div class=\"polling\">\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u0423\u0440\u043e\u043a \u043f\u043e\u043b\u0435\u0437\u0435\u043d?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"165251\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"6863\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv36117\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"36117\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv36117\">\u0434\u0430<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv36119\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"36119\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv36119\">\u043d\u0435\u0442<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"for_users_only_msg\">\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a href=\"\/login\/\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/p>\n<p class=\"total\">\u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<\/p><\/div>\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\/165251\/\"> http:\/\/habrahabr.ru\/post\/165251\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e!<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u043e\u0439 \u043c\u043d\u043e\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/165105\/\">\u0447\u0430\u0441\u0442\u0438 1<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435 <\/h4>\n<p>  <b>\u0412\u0430\u0436\u043d\u043e<\/b>: \u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0440\u043e\u043a \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c. \u0410\u0432\u0442\u043e\u0440 \u0443\u0440\u043e\u043a\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u043c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b Android. \u042f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u043d\u043e\u0448\u0443 \u0441\u0432\u043e\u0438 \u0438\u0437\u0432\u0438\u043d\u0435\u043d\u0438\u044f, \u0437\u0430 \u043d\u0435\u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<h4>RegistrationActivity<\/h4>\n<p>  \u0412 Activity \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/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-165251","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165251","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=165251"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165251\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}