<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1830398599758101838</id><updated>2024-11-01T16:57:54.288+09:00</updated><category term="ListView"/><category term="Bluetooth"/><category term="データベース"/><category term="アラートダイアログ"/><category term="Service"/><category term="カメラ"/><category term="WebView"/><category term="iPhone"/><category term="画面遷移"/><category term="View"/><category term="定期処理"/><category term="TextView"/><category term="AFreeChart"/><category term="Android"/><category term="画像関係"/><category term="Androidplot"/><category term="Chronometer"/><category term="Eclipse"/><category term="USB Host"/><category term="assets"/><category term="ADK"/><category term="GPS"/><category term="Java"/><category term="NanoHTTPD"/><category term="ViewFlipper"/><category term="ViewSwicher"/><category term="javaリファレンス"/><category term="インターネット"/><category term="エラー対策"/><category term="ソースコードリーディング"/><category term="ネットワーク"/><category term="ビルド"/><category term="Activity"/><category term="MapView"/><category term="NDK"/><category term="http通信"/><category term="mail"/><category term="xm"/><category term="xml"/><category term="メール関係"/><title type='text'>Androidアプリ開発に挑戦</title><subtitle type='html'>2011/02/28 からの個人的なメモ　正確な情報は他のサイトで確認して下さい。</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>273</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-6620370044512967109</id><published>2015-10-10T17:03:00.000+09:00</published><updated>2012-09-05T12:35:01.914+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>はじめに:2011/02/28</title><content type='html'>iPhoneアプリをiPhone実機でテストするには、iOS Devloper Programへ登録が必要で、&lt;br /&gt;
年間参加費は10,800円のようです。&lt;br /&gt;
Macも必要との事。気軽には出来ない&lt;br /&gt;
ななんとか、Windowsで開発出来ないかと思って検索してみると、いくつか方法があるようです。&lt;br /&gt;
&lt;br /&gt;
Androidの方がハードルが低そうです。&lt;br /&gt;
&lt;br /&gt;
記事はすべて左のメニューからアクセス出来ます。&lt;br /&gt;
質問されても、知識が無いので答えられません。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/6620370044512967109/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2011/02/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6620370044512967109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6620370044512967109'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2011/02/blog-post.html' title='はじめに:2011/02/28'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-6777294921223866913</id><published>2014-02-21T10:38:00.000+09:00</published><updated>2014-02-21T10:38:50.932+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AFreeChart"/><title type='text'>AFreeChartで積立グラフ</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKKhmDQZ0rAgXOzg_1P4cOuOLh1GunG8KQOCC8TO7t7kGoSjN03Rf4cU1U6W4qkzs1r9bS-RcXsfS392J8WdKLstvlHfG8oTIO3eIlm2G86a14TF1U_BoUBA6lhl_-IelKBUSF2tmltzh/s1600/device-2014-02-21-103417.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKKhmDQZ0rAgXOzg_1P4cOuOLh1GunG8KQOCC8TO7t7kGoSjN03Rf4cU1U6W4qkzs1r9bS-RcXsfS392J8WdKLstvlHfG8oTIO3eIlm2G86a14TF1U_BoUBA6lhl_-IelKBUSF2tmltzh/s1600/device-2014-02-21-103417.png&quot; height=&quot;192&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9127220.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/6777294921223866913/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart_21.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6777294921223866913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6777294921223866913'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart_21.html' title='AFreeChartで積立グラフ'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKKhmDQZ0rAgXOzg_1P4cOuOLh1GunG8KQOCC8TO7t7kGoSjN03Rf4cU1U6W4qkzs1r9bS-RcXsfS392J8WdKLstvlHfG8oTIO3eIlm2G86a14TF1U_BoUBA6lhl_-IelKBUSF2tmltzh/s72-c/device-2014-02-21-103417.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-5971965431046995703</id><published>2014-02-20T14:55:00.002+09:00</published><updated>2014-02-21T10:31:23.517+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AFreeChart"/><title type='text'>棒グラフ：XYBarRenderer</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH63Qm9YbukjZ1nPp2jPeMMw9YDrqQCez9ePNcw9vXIdEUhd_MBeulpZ9uwPAbB0h2DplNNLRulKcJ1-_xpJLbeUZXqlVRLWp_yax0KdWl531EGuIgTqvPX3vfYyQ6QnZg7afFtK22Uu3E/s1600/device-2014-02-20-145129.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH63Qm9YbukjZ1nPp2jPeMMw9YDrqQCez9ePNcw9vXIdEUhd_MBeulpZ9uwPAbB0h2DplNNLRulKcJ1-_xpJLbeUZXqlVRLWp_yax0KdWl531EGuIgTqvPX3vfYyQ6QnZg7afFtK22Uu3E/s1600/device-2014-02-20-145129.png&quot; height=&quot;192&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/12f2072e79ae810999bc.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/fbc1b246ffbd3aa08f1d.js?file=GraphView.java&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/fbc1b246ffbd3aa08f1d.js?file=activity_main.xml&quot;&gt;&lt;/script&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/5971965431046995703/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/xybarrenderer.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5971965431046995703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5971965431046995703'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/xybarrenderer.html' title='棒グラフ：XYBarRenderer'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH63Qm9YbukjZ1nPp2jPeMMw9YDrqQCez9ePNcw9vXIdEUhd_MBeulpZ9uwPAbB0h2DplNNLRulKcJ1-_xpJLbeUZXqlVRLWp_yax0KdWl531EGuIgTqvPX3vfYyQ6QnZg7afFtK22Uu3E/s72-c/device-2014-02-20-145129.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-2134175184131365920</id><published>2014-02-20T13:34:00.000+09:00</published><updated>2014-02-20T13:34:23.304+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AFreeChart"/><title type='text'>AFreeChartで棒グラフ</title><content type='html'>AFreeChartのサンプルのデモを参考にやってみる。&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/afreechart/source/browse/trunk/afreechart_sample/src/org/afree/chart/demo/view/BarChartDemo1View.java?r=41&quot;&gt;https://code.google.com/p/afreechart/source/browse/trunk/afreechart_sample/src/org/afree/chart/demo/view/BarChartDemo1View.java?r=41&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj58gNaJgk7r1CDRA_ua0jCeH6aAnARkOw5D0C4Td5e5A-WJSN9aFa3j08IRiazm4XLJEwl9zckjAxLNsAqzv9i1A_yubCB5P9u_8em6l-5DJCDajVY3bWuCPryQUqlMjKBMATLCj1ztgwJ/s1600/device-2014-02-20-132831.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj58gNaJgk7r1CDRA_ua0jCeH6aAnARkOw5D0C4Td5e5A-WJSN9aFa3j08IRiazm4XLJEwl9zckjAxLNsAqzv9i1A_yubCB5P9u_8em6l-5DJCDajVY3bWuCPryQUqlMjKBMATLCj1ztgwJ/s1600/device-2014-02-20-132831.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/fbc1b246ffbd3aa08f1d.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/2134175184131365920/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart_20.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2134175184131365920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2134175184131365920'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart_20.html' title='AFreeChartで棒グラフ'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj58gNaJgk7r1CDRA_ua0jCeH6aAnARkOw5D0C4Td5e5A-WJSN9aFa3j08IRiazm4XLJEwl9zckjAxLNsAqzv9i1A_yubCB5P9u_8em6l-5DJCDajVY3bWuCPryQUqlMjKBMATLCj1ztgwJ/s72-c/device-2014-02-20-132831.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-3935088601419545666</id><published>2014-02-20T11:08:00.000+09:00</published><updated>2014-02-20T11:26:30.620+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AFreeChart"/><title type='text'>AFreeChartでグラフ作成</title><content type='html'>1.ライブラリ：afreechart-0.0.4.jar　をダウンロードして、libs フォルダに入れる。&lt;br /&gt;
2.view を作成する。&lt;br /&gt;
3.データを入れる。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaOTiRGheQ2ACuD4F5qFKUHH2EDfFUe4AQQv0_8ZUkauGy0fG59KOeKu_84VMEP41OXVPuh2dOA9qjrPfFhCQwtQIQo8zIhW-KhKgFaQMymgIohf6BFpTulSzmW9KRyk9we0bdIO8rLqVn/s1600/device-2014-02-20-111324edited.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaOTiRGheQ2ACuD4F5qFKUHH2EDfFUe4AQQv0_8ZUkauGy0fG59KOeKu_84VMEP41OXVPuh2dOA9qjrPfFhCQwtQIQo8zIhW-KhKgFaQMymgIohf6BFpTulSzmW9KRyk9we0bdIO8rLqVn/s1600/device-2014-02-20-111324edited.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9105714.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/3935088601419545666/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3935088601419545666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3935088601419545666'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/afreechart.html' title='AFreeChartでグラフ作成'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaOTiRGheQ2ACuD4F5qFKUHH2EDfFUe4AQQv0_8ZUkauGy0fG59KOeKu_84VMEP41OXVPuh2dOA9qjrPfFhCQwtQIQo8zIhW-KhKgFaQMymgIohf6BFpTulSzmW9KRyk9we0bdIO8rLqVn/s72-c/device-2014-02-20-111324edited.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-6429202082579728988</id><published>2014-02-19T10:29:00.001+09:00</published><updated>2014-02-19T12:05:35.656+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Androidplot"/><title type='text'>積み上げグラフに挑戦</title><content type='html'>&lt;a href=&quot;http://yamato-iphone.blogspot.jp/2014/02/blog-post.html&quot;&gt;棒グラフに挑戦&lt;/a&gt;　のソースコードを、AndroidplotのDocsのExamplesにある&lt;a href=&quot;https://bitbucket.org/androidplot/androidplot/src/master/Examples/DemoApp/src/com/androidplot/demos/BarPlotExampleActivity.java?at=master&quot;&gt;Bar Plot&lt;/a&gt;　を参考変更する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEJRC5r1eOorU4Zw0T1KJyiasVY1hq5NxCuqYPTLxxIxC3PVcA1RkRn_FQXFDkHzNFTpOGBoH1MNNheiqEjCI6SFRYpVCOkgzXhOTNl0y7K9gwRvH8-JTlu0JEDov99NWGwuNYYxdQko-2/s1600/device-2014-02-19-105204.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEJRC5r1eOorU4Zw0T1KJyiasVY1hq5NxCuqYPTLxxIxC3PVcA1RkRn_FQXFDkHzNFTpOGBoH1MNNheiqEjCI6SFRYpVCOkgzXhOTNl0y7K9gwRvH8-JTlu0JEDov99NWGwuNYYxdQko-2/s1600/device-2014-02-19-105204.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9084671.js?file=MainActivity.java&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;hr /&gt;
plot.setRangeBoundaries(0, 10, BoundaryMode.FIXED);//Y軸　0-10
plot.setRangeValueFormat(new DecimalFormat(&quot;0&quot;));//整数&lt;br /&gt;
&lt;br /&gt;
上記のコードは、7.8を7と表示しているのでおかしくなっているので修正する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ISIjNkla1-Y_oEj2AroBPH8k2KeikOpzNDTQop01ojlD_l1JCpvaZxjxHH-BaoJm4PlUmxpPw4TG-IxRpANSekrkdNDJnQyk3zNwTmuFBnodJe6t8J0VhCpDh0SmYFt8Mv4NiEPZWwnd/s1600/device-2014-02-19-115515.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ISIjNkla1-Y_oEj2AroBPH8k2KeikOpzNDTQop01ojlD_l1JCpvaZxjxHH-BaoJm4PlUmxpPw4TG-IxRpANSekrkdNDJnQyk3zNwTmuFBnodJe6t8J0VhCpDh0SmYFt8Mv4NiEPZWwnd/s1600/device-2014-02-19-115515.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
plot.setRangeBoundaries(0, 10, BoundaryMode.FIXED);//Y軸　0-10 
plot.setRangeStep(XYStepMode.SUBDIVIDE, 11);&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/6429202082579728988/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/blog-post_19.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6429202082579728988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/6429202082579728988'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/blog-post_19.html' title='積み上げグラフに挑戦'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEJRC5r1eOorU4Zw0T1KJyiasVY1hq5NxCuqYPTLxxIxC3PVcA1RkRn_FQXFDkHzNFTpOGBoH1MNNheiqEjCI6SFRYpVCOkgzXhOTNl0y7K9gwRvH8-JTlu0JEDov99NWGwuNYYxdQko-2/s72-c/device-2014-02-19-105204.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-215622073311873945</id><published>2014-02-18T16:15:00.000+09:00</published><updated>2014-02-19T10:23:24.120+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Androidplot"/><title type='text'>棒グラフに挑戦</title><content type='html'>とりあえず表示してみる&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM-phS1kp9RR7ksZOc_BzIZak8WrNuNZM-2kxRu845u7wgcSc0qFgo3IEDUN17iFmcROviuMMN5HWH0JxSogTSxwqlS_AOugSiKLqncYhh_Ni3zJdciBqXy4L1oUHoPhha8ImMo53udsVl/s1600/device-2014-02-18-161700.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM-phS1kp9RR7ksZOc_BzIZak8WrNuNZM-2kxRu845u7wgcSc0qFgo3IEDUN17iFmcROviuMMN5HWH0JxSogTSxwqlS_AOugSiKLqncYhh_Ni3zJdciBqXy4L1oUHoPhha8ImMo53udsVl/s1600/device-2014-02-18-161700.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/ed136a62122277f97d16.js?file=activity_main.xml&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist.github.com/yamato8/ed136a62122277f97d16.js?file=MainActivity.java&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;a href=&quot;http://androidplot.com/docs/quickstart/&quot;&gt;Quickstart&lt;/a&gt;のDynamically Plotting Sensor Dataのソースを見ながら調整していく。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS8uygeQNqKrxNtbxZwNHOebMciFvpg3ViBQI81rsD2vfd5eJzrFbnlBnMGdEiS4YEtQtdSFG_erVAZllFHm9bK_u2GQfPPHJCfLn_rXEIVtHM7q28dgABwKu0rOs5DkhtuoHDmFtI8LtB/s1600/device-2014-02-19-101728.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS8uygeQNqKrxNtbxZwNHOebMciFvpg3ViBQI81rsD2vfd5eJzrFbnlBnMGdEiS4YEtQtdSFG_erVAZllFHm9bK_u2GQfPPHJCfLn_rXEIVtHM7q28dgABwKu0rOs5DkhtuoHDmFtI8LtB/s1600/device-2014-02-19-101728.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/ed136a62122277f97d16.js?file=MainActivity2.java&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/215622073311873945/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/215622073311873945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/215622073311873945'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/blog-post.html' title='棒グラフに挑戦'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM-phS1kp9RR7ksZOc_BzIZak8WrNuNZM-2kxRu845u7wgcSc0qFgo3IEDUN17iFmcROviuMMN5HWH0JxSogTSxwqlS_AOugSiKLqncYhh_Ni3zJdciBqXy4L1oUHoPhha8ImMo53udsVl/s72-c/device-2014-02-18-161700.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-3350465559537654096</id><published>2014-02-17T12:12:00.002+09:00</published><updated>2014-02-18T16:15:29.548+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Androidplot"/><title type='text'>Androidplotに挑戦</title><content type='html'>Androidplot はアンドロイドでグラフを描くときに使うライブラリ&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://androidplot.com/docs/quickstart/&quot;&gt;Quickstart&lt;/a&gt;&amp;nbsp;を参考にやってみる&lt;br /&gt;
&lt;br /&gt;
ライブラリ：androidplot-core-0.6.0.jarを&lt;a href=&quot;http://androidplot.com/download/&quot;&gt;http://androidplot.com/download/&lt;/a&gt;　からダウンロードしてくる。&lt;br /&gt;
&lt;br /&gt;
プロジェクトを作成する。&lt;br /&gt;
&lt;br /&gt;
libs フォルダにライブラリを入れる。&lt;br /&gt;
&lt;br /&gt;
レイアウトファイル activity_main.xml を作成する。&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9044039.js?file=activity_main.xml&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
グラフィカルレイアウト画面ではエラーが確認できるが、よく分からないので無視して進む。&lt;br /&gt;
この時点で実行すると下記のように表示される。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ_J2qogf5MESkCwgzuBYWqT-Q-L_gfM1k_onR6XSQNtNPP7-4LgNI2m2KEkS_e7c_FIfS8w0RM1PgMLpYUU2C6MfvRVZqeP_JWWznQQxMcQxILNHixHcMp3je4hpYesMy7nSn47BHpNzC/s1600/142.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ_J2qogf5MESkCwgzuBYWqT-Q-L_gfM1k_onR6XSQNtNPP7-4LgNI2m2KEkS_e7c_FIfS8w0RM1PgMLpYUU2C6MfvRVZqeP_JWWznQQxMcQxILNHixHcMp3je4hpYesMy7nSn47BHpNzC/s1600/142.png&quot; height=&quot;320&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
グラフデータをセットする。&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9044039.js?file=MainActivity.java&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4wTqv9-9T_pvGsKpeWLCN9kQoF2TJThpcT3OznbVHa1mt4IpCcluGX811hFS1oy7XOv3rCAdY_SyRzuIZue5hhYy9PinqhdOOPI8zbTDk2MFTRh9klnOvm-EZCeQU5Le8bAdfbl1LaHdY/s1600/143.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4wTqv9-9T_pvGsKpeWLCN9kQoF2TJThpcT3OznbVHa1mt4IpCcluGX811hFS1oy7XOv3rCAdY_SyRzuIZue5hhYy9PinqhdOOPI8zbTDk2MFTRh9klnOvm-EZCeQU5Le8bAdfbl1LaHdY/s1600/143.png&quot; height=&quot;320&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
色々調整してみる&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhps8FsBWbr_4mEMwW6VyX8tVJi4xKOZxS0HaTSBTsASgr29fYyVIuN-3pEeT1vHNvhGc4c2u5RcV7T6SvQZUAp90axn5apB5BHXsqEmew7NVI5dTMVh_jAJzvMtfwh381r7YF2aoz21IZZ/s1600/144.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhps8FsBWbr_4mEMwW6VyX8tVJi4xKOZxS0HaTSBTsASgr29fYyVIuN-3pEeT1vHNvhGc4c2u5RcV7T6SvQZUAp90axn5apB5BHXsqEmew7NVI5dTMVh_jAJzvMtfwh381r7YF2aoz21IZZ/s1600/144.png&quot; height=&quot;320&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/9044039.js?file=MainActivity2.java&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
ラインの色、太さ、ポイントの色、塗り潰し色、文字の色
&lt;script src=&quot;https://gist.github.com/yamato8/9044039.js?file=line_point_formatter_with_plf1.xml&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/3350465559537654096/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/androidplot.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3350465559537654096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3350465559537654096'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/androidplot.html' title='Androidplotに挑戦'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ_J2qogf5MESkCwgzuBYWqT-Q-L_gfM1k_onR6XSQNtNPP7-4LgNI2m2KEkS_e7c_FIfS8w0RM1PgMLpYUU2C6MfvRVZqeP_JWWznQQxMcQxILNHixHcMp3je4hpYesMy7nSn47BHpNzC/s72-c/142.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-7693915830753370952</id><published>2014-02-13T07:32:00.001+09:00</published><updated>2014-02-14T10:14:43.486+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="USB Host"/><title type='text'>android-mbed usb serial</title><content type='html'>mbedに付いているUSBとアンドロイドをUSBホストケーブルで接続して送受信をする。&lt;br /&gt;
&lt;br /&gt;
USBディバイスを接続した時点で、実行するアプリを選択する。&lt;br /&gt;
&lt;br /&gt;
AndroidManifest.xml のinternt-filterの中を修正する&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/8965808.js?file=AndroidManifest.xml&quot;&gt;&lt;/script&gt;

&lt;a href=&quot;http://usb-serial-for-android.googlecode.com/git/UsbSerialExamples/res/xml/device_filter.xml&quot;&gt;device_filter.xml&lt;/a&gt;をダウンロードしてきてmbedのベンダーＩＤを追記する&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/8965808.js?file=device_filter.xml&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
この時点でインストールしてmbedと接続すると。下の様になる。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpXK6a3JpqoqM0xtKA9zwG5LN0c7DrDIKRTqNplF0n92_b8a9RPmfTIibAG4yqx5QCIskJnRsocxjgtVNAS9hsoAru4qAwPnbQDPS6udx9ewg8HUwwwrXwVG2F0EZUNfFNQNZ2rMqN11Q_/s1600/Screenshot_2014-02-13-07-12-48.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpXK6a3JpqoqM0xtKA9zwG5LN0c7DrDIKRTqNplF0n92_b8a9RPmfTIibAG4yqx5QCIskJnRsocxjgtVNAS9hsoAru4qAwPnbQDPS6udx9ewg8HUwwwrXwVG2F0EZUNfFNQNZ2rMqN11Q_/s1600/Screenshot_2014-02-13-07-12-48.png&quot; height=&quot;320&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
シリアル通信するには、&lt;br /&gt;
&lt;a href=&quot;http://ksksue.com/wiki/doku.php?id=wiki:android:hardware:usb:ftdriver&quot;&gt;FTDrvier : Android USBシリアルドライバ&lt;/a&gt;を使うのがよさそうです。&lt;br /&gt;
&lt;br /&gt;
mbed のピンD-,D+を使う場合、vendor-id=&quot;7936&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ksksue.com/wiki/doku.php?id=wiki:android:app:usbserialmonitorlite&quot;&gt;Android USB Serial Monitor Lite&lt;/a&gt;&amp;nbsp;では、p31 (D+), p32 (D-) and GNDを使った接続と、&lt;br /&gt;
実装されているusb どちらでも使うことができた。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://mbed.org/handbook/USBSerial&quot;&gt;USBSerial_HelloWorld&lt;/a&gt;&amp;nbsp;と　p31 (D+), p32 (D-) and GND　接続の場合&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_hT7wYz0rjcvYeLWgAzr51I4ARYP92KPtC7O8NbB3OovhEgUprtpIAPHcGgR_ZQJPsxSVAYgI6lPvtpc8Vt0sjGOvmae1INM9HADL4cFNZ1x9q5-4pVMSt6931vhbNAVnHx9qDPan6FXA/s1600/Screenshot_2014-02-14-10-12-56.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_hT7wYz0rjcvYeLWgAzr51I4ARYP92KPtC7O8NbB3OovhEgUprtpIAPHcGgR_ZQJPsxSVAYgI6lPvtpc8Vt0sjGOvmae1INM9HADL4cFNZ1x9q5-4pVMSt6931vhbNAVnHx9qDPan6FXA/s1600/Screenshot_2014-02-14-10-12-56.png&quot; height=&quot;320&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/7693915830753370952/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/usbmbed.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/7693915830753370952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/7693915830753370952'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/usbmbed.html' title='android-mbed usb serial'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpXK6a3JpqoqM0xtKA9zwG5LN0c7DrDIKRTqNplF0n92_b8a9RPmfTIibAG4yqx5QCIskJnRsocxjgtVNAS9hsoAru4qAwPnbQDPS6udx9ewg8HUwwwrXwVG2F0EZUNfFNQNZ2rMqN11Q_/s72-c/Screenshot_2014-02-13-07-12-48.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-890253381764873670</id><published>2014-02-12T09:12:00.000+09:00</published><updated>2014-02-12T09:54:48.405+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="USB Host"/><title type='text'>アンドロイドとmbedをUSBで繋げてみる。</title><content type='html'>mbedのUSBポートとアンドロイドをUSBホストケーブルで接続する。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8R1QlFfpSa5Yp3vhRHtVEjGhlYiPibjxlUEoSPer-fO_IraUl5POFXzNhxDPHp41weRm9ruky_MfZwaWlhARzzc3ctYARJltWG-aE0Qtgfzjb8TErvenjFRO2kxk6z7uX9_ztelVnYekF/s1600/Screenshot_2014-02-12-09-03-33.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8R1QlFfpSa5Yp3vhRHtVEjGhlYiPibjxlUEoSPer-fO_IraUl5POFXzNhxDPHp41weRm9ruky_MfZwaWlhARzzc3ctYARJltWG-aE0Qtgfzjb8TErvenjFRO2kxk6z7uX9_ztelVnYekF/s1600/Screenshot_2014-02-12-09-03-33.png&quot; height=&quot;320&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
使用アプリ：Android USB Serial Monitor Lite&lt;br /&gt;
使用ケーブル：エレコムのU2HS-MB02-4S&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicaqylAg8vD40FqTSR-lQjQVpvtJU9W1LToZKn_DrbmXmiVRIGT1p0QBvemRE3U2en8oLtmqJy1w-oLbysyI_2VLpJaUr_jkHuZwOaS-F3pSBD6_DZK3Mn3LyBap9Qys2sHHIyHIXWQgTw/s1600/110.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicaqylAg8vD40FqTSR-lQjQVpvtJU9W1LToZKn_DrbmXmiVRIGT1p0QBvemRE3U2en8oLtmqJy1w-oLbysyI_2VLpJaUr_jkHuZwOaS-F3pSBD6_DZK3Mn3LyBap9Qys2sHHIyHIXWQgTw/s1600/110.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
mbed側のプログラム&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/yamato8/8947253.js&quot;&gt;&lt;/script&gt;
0.5秒毎にmbedからアンドロイドに、Hello Worldを送信、&lt;br /&gt;
アンドロイドから　mbed に文字を送信したら、mbedは割り込みで受信して、&lt;br /&gt;
アンドロイドにその文字を送り返す。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/890253381764873670/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/mbedusb.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/890253381764873670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/890253381764873670'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2014/02/mbedusb.html' title='アンドロイドとmbedをUSBで繋げてみる。'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8R1QlFfpSa5Yp3vhRHtVEjGhlYiPibjxlUEoSPer-fO_IraUl5POFXzNhxDPHp41weRm9ruky_MfZwaWlhARzzc3ctYARJltWG-aE0Qtgfzjb8TErvenjFRO2kxk6z7uX9_ztelVnYekF/s72-c/Screenshot_2014-02-12-09-03-33.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-1046155561628915959</id><published>2013-12-23T10:40:00.000+09:00</published><updated>2013-12-23T14:26:32.714+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="USB Host"/><title type='text'>USB Host　に挑戦</title><content type='html'>アンドロイドのドキュメント：&lt;a href=&quot;http://developer.android.com/guide/topics/connectivity/usb/host.html&quot;&gt;USB Host&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
USBディバイスはMbed を使いました。&lt;br /&gt;
&lt;br /&gt;
参考サイト：kshoji:&lt;a href=&quot;http://blog.kshoji.jp/2012/12/android-usb-host.html&quot;&gt;自作のUSBデバイスを、Androidで動かす&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
参考サイトに詳細に解説されています。&lt;br /&gt;
&lt;br /&gt;
参考サイトの一部必要な所だけ取り出してみました。&lt;br /&gt;
&lt;br /&gt;
とりあえず、Mbed に送信してLED4を点灯させてみる。&lt;br /&gt;
点灯と消灯の二つのボタンを置いて操作する。&lt;br /&gt;
USBディバイスを接続した時に使うアプリを聞いてくる。&lt;br /&gt;
&lt;br /&gt;
回路図：アンドロイドとUSBホストケーブルで接続する&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6K0Pku00M2nSEX1ip494EqdeMsGGLHs_DTbBU_2ZGjsOrrW-SF_QcBAXgjTXFADV3wgGzkuqC7B9xS2HyPjBDWn90oNU_LaMULIOhToXnEcS9EnC_ayGbO92dFbyQzWQILN7Gw8G5Eget/s1600/024.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6K0Pku00M2nSEX1ip494EqdeMsGGLHs_DTbBU_2ZGjsOrrW-SF_QcBAXgjTXFADV3wgGzkuqC7B9xS2HyPjBDWn90oNU_LaMULIOhToXnEcS9EnC_ayGbO92dFbyQzWQILN7Gw8G5Eget/s320/024.png&quot; width=&quot;277&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Mbed のソースコード：参考サイトのソースコードをそのまま使いました。&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;#include &quot;mbed.h&quot;
#include &quot;USBHID.h&quot;

// device
USBHID hid;

// read
HID_REPORT recv;
BusOut leds(LED1, LED2, LED3, LED4);

// write
HID_REPORT send;
AnalogIn input(p15);

int main(void)
{
    int lastData = 0;
    int currentData;

    send.length = 64;
    while (1) {
        // read
        hid.readNB(&amp;amp;recv);
        if (recv.length &amp;gt; 0) {
            leds = recv.data[0];
            
        }

        currentData = input.read_u16();
        if (currentData != lastData) {
            lastData = currentData;

            // write
            send.data[0] = (currentData &amp;gt;&amp;gt; 8) &amp;amp; 0xff;
            send.data[1] = currentData &amp;amp; 0xff;
            //hid.send(&amp;amp;send);
        }
        
    }
}
&lt;/pre&gt;
&lt;br /&gt;
アンドロイドアプリのソースコード&lt;br /&gt;
エラー処理や例外・終了処理は考慮していない。&lt;br /&gt;
AndroidManifest.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.example.hidtest002&quot;
    android:installLocation=&quot;preferExternal&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot; &amp;gt;

    &amp;lt;uses-sdk
        android:minSdkVersion=&quot;12&quot;
        android:targetSdkVersion=&quot;17&quot; /&amp;gt;

    &amp;lt;application
        android:allowBackup=&quot;true&quot;
        android:icon=&quot;@drawable/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot;
        android:theme=&quot;@style/AppTheme&quot; &amp;gt;
        &amp;lt;activity
            android:name=&quot;com.example.hidtest002.MainActivity&quot;
            android:label=&quot;@string/app_name&quot; &amp;gt;

            &amp;lt;intent-filter&amp;gt;
                &amp;lt;action android:name=&quot;android.hardware.usb.action.USB_DEVICE_ATTACHED&quot; /&amp;gt;
            &amp;lt;/intent-filter&amp;gt;

            &amp;lt;meta-data
                android:name=&quot;android.hardware.usb.action.USB_DEVICE_ATTACHED&quot;
                android:resource=&quot;@xml/device_filter&quot; /&amp;gt;
        &amp;lt;/activity&amp;gt;
    &amp;lt;/application&amp;gt;

&amp;lt;/manifest&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
res/xml/device_filter.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;resources&amp;gt;
    &amp;lt;!-- Interface class: USB HID --&amp;gt;
    &amp;lt;usb-device class=&quot;3&quot; subclass=&quot;0&quot; protocol=&quot;0&quot; /&amp;gt;
&amp;lt;/resources&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
MainActivity.java&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.hidtest002;

import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener {

 private static final String TAG = &quot;HidTest&quot;;
 private TextView text;
 private UsbDeviceConnection deviceConnection = null;
 private UsbEndpoint outputEndpoint2;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  text = (TextView) findViewById(R.id.textView1);

  // 　ボタンがクリックされた時の処理
  Button btn1 = (Button) findViewById(R.id.button1);
  btn1.setOnClickListener(this);
  Button btn2 = (Button) findViewById(R.id.button2);
  btn2.setOnClickListener(this);

  // 　USB ディバイスが接続されていない時は終了
  if (!UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(getIntent().getAction())) {
   finish();
  } else {
   // USB ディバイスを接続
   Intent intent = getIntent();
   UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
   if (device != null) {
    Log.v(TAG, &quot;UsbDevice　がある&quot;);
    UsbInterface usbInterface = findUsbInterface(device);
    if (usbInterface != null) {
     // アタッチ
     UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
     deviceConnection = usbManager.openDevice(device);
     deviceConnection.claimInterface(usbInterface, true);
    }
   }
  }

 }

 /*
  * UsbInterface の確認　
  */
 private UsbInterface findUsbInterface(UsbDevice device) {
  // TODO 自動生成されたメソッド・スタブ
  text.setText(&quot;UsbDevice.getDeviceName():&quot; + device.getDeviceName() + &quot;\n&quot;);
  int count = device.getInterfaceCount();// 4
  text.append(&quot;UsbDevice.getInterfaceCount():&quot; + count + &quot;\n&quot;);
  for (int i = 0; i &amp;lt; count; i++) {
   UsbInterface usbInterface = device.getInterface(i);

   UsbEndpoint inputEndpoint = null;
   UsbEndpoint outputEndpoint = null;

   text.append(&quot;**************************&quot; + &quot;\n&quot;);
   text.append(&quot; UsbInterface.getEndpointCount():&quot; + usbInterface.getEndpointCount() + &quot;\n&quot;);
   if (usbInterface.getEndpointCount() &amp;gt;= 1) {
    for (int endpointIndex = 0; endpointIndex &amp;lt; usbInterface.getEndpointCount(); endpointIndex++) {
     UsbEndpoint endpoint = usbInterface.getEndpoint(endpointIndex);
     text.append(endpointIndex + &quot;:&quot;);

     if ((endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK || endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT)) {
      if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
       outputEndpoint = outputEndpoint == null ? endpoint : outputEndpoint;
       outputEndpoint2 = endpoint;
       text.append(&quot;  UsbEndpoint:getDirection()&quot; + endpoint.getDirection() + &quot;\n&quot;);// USB_DIR_OUT
      }
     }
    }

    if (inputEndpoint != null || outputEndpoint != null) {
     return usbInterface;
    }
   }
  }

  return null;
 }

 /*
  * ボタンが押された時の処理
  */
 @Override
 public void onClick(View v) {
  // TODO 自動生成されたメソッド・スタブ
  byte data1 = 0;
  byte data2 = 0;
  byte data3 = 0;
  byte data4 = 0;

  switch (v.getId()) {
  case R.id.button1:
   Log.i(&quot;buttonTest&quot;, &quot;点灯ボタンが押された&quot;);
   data1 = 0;
   data2 = 0;
   data3 = 0;
   data4 = (byte) 8;
   break;
  case R.id.button2:
   Log.i(&quot;buttonTest&quot;, &quot;消灯ボタンが押された&quot;);
   data1 = 0;
   data2 = 0;
   data3 = 0;
   data4 = 0;
   break;

  }
  outPutMbed(new byte[] { (byte) (data1 | data2 | data3 | data4) });

 }

 // Mbed に送信
 private void outPutMbed(byte[] bytes) {
  // TODO 自動生成されたメソッド・スタブ
  final int maxPacketSize = outputEndpoint2.getMaxPacketSize();
  for (int i = 0; i &amp;lt; bytes.length; i += maxPacketSize) {
   byte[] writeBuffer = new byte[maxPacketSize];
   int length = (bytes.length - i) &amp;lt; writeBuffer.length ? bytes.length - i : writeBuffer.length;
   System.arraycopy(bytes, i, writeBuffer, 0, length);
   deviceConnection.bulkTransfer(outputEndpoint2, writeBuffer, writeBuffer.length, 0);
  }
 }

 /*
  * メニューの処理
  */
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.itemFinish:
   Log.v(TAG, &quot;finish&quot;);
   finish();
   return true;
  }

  return false;
 }
}
&lt;/pre&gt;
&lt;br /&gt;
activity_main.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot;
    android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;
    android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;
    android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;
    tools:context=&quot;.MainActivity&quot; &amp;gt;

    &amp;lt;LinearLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot;
        android:orientation=&quot;vertical&quot; &amp;gt;

        &amp;lt;LinearLayout
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;wrap_content&quot; &amp;gt;

            &amp;lt;Button
                android:id=&quot;@+id/button1&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:text=&quot;点灯&quot; /&amp;gt;

            &amp;lt;Button
                android:id=&quot;@+id/button2&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:text=&quot;消灯&quot; /&amp;gt;

        &amp;lt;/LinearLayout&amp;gt;

        &amp;lt;LinearLayout
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;match_parent&quot;
            android:orientation=&quot;vertical&quot; &amp;gt;

            &amp;lt;TextView
                android:id=&quot;@+id/textView1&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:text=&quot;@string/hello_world&quot; /&amp;gt;

        &amp;lt;/LinearLayout&amp;gt;

    &amp;lt;/LinearLayout&amp;gt;

&amp;lt;/RelativeLayout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/1046155561628915959/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/12/usb-host.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1046155561628915959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1046155561628915959'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/12/usb-host.html' title='USB Host　に挑戦'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6K0Pku00M2nSEX1ip494EqdeMsGGLHs_DTbBU_2ZGjsOrrW-SF_QcBAXgjTXFADV3wgGzkuqC7B9xS2HyPjBDWn90oNU_LaMULIOhToXnEcS9EnC_ayGbO92dFbyQzWQILN7Gw8G5Eget/s72-c/024.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-2540833227858995760</id><published>2013-10-06T13:45:00.002+09:00</published><updated>2013-10-06T15:46:39.283+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Service"/><title type='text'>IntentService を使ってみる：android</title><content type='html'>&lt;a href=&quot;http://developer.android.com/guide/components/services.html&quot;&gt;http://developer.android.com/guide/components/services.html&lt;/a&gt;&amp;nbsp;で紹介されているソースコードを実行してみる。&lt;br /&gt;
サービスの終了操作を気にしないでいいようです。&lt;br /&gt;
５秒後にサービス終了するコード。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  Intent intent = new Intent(this, HelloIntentService.class);
  startService(intent);
 }
}

&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import android.app.IntentService;
import android.content.Intent;
import android.util.Log;

public class HelloIntentService extends IntentService {

 private static final String TAG = &quot;HelloIntentService&quot;;

 /** 
  * A constructor is required, and must call the super IntentService(String)
  * constructor with a name for the worker thread.
  */
 public HelloIntentService() {
  super(&quot;HelloIntentService&quot;);

  Log.v(TAG, &quot;HelloIntentService&quot;);
 }

 /**
  * The IntentService calls this method from the default worker thread with
  * the intent that started the service. When this method returns, IntentService
  * stops the service, as appropriate.
  */
 @Override
 protected void onHandleIntent(Intent intent) {
  Log.v(TAG, &quot;onHandleIntent&quot;);

  // Normally we would do some work here, like download a file.
  // For our sample, we just sleep for 5 seconds.
  long endTime = System.currentTimeMillis() + 5 * 1000;
  while (System.currentTimeMillis() &amp;lt; endTime) {
   synchronized (this) {
    try {
     wait(endTime - System.currentTimeMillis());
    } catch (Exception e) {
    }
   }
  }
  Log.v(TAG, &quot;onHandleIntent 終了&quot;);
 }

 @Override
 public void onDestroy() {
  Log.v(TAG, &quot;onDestroy&quot;);
 }

}

&lt;/pre&gt;
&lt;hr /&gt;
UIの変更を考えてみる&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.widget.TextView;

public class MainActivity extends Activity {

 public static class SampleHandler extends Handler {
  private MainActivity con;

  public SampleHandler(MainActivity mainActivity) {
   // TODO 自動生成されたコンストラクター・スタブ
   this.con = mainActivity;
  }

  @Override
  public void handleMessage(Message msg) {
   Bundle bundle = msg.getData();
   
    TextView textView = (TextView) con.findViewById(R.id.textView1);
    textView.setText( bundle.getString(&quot;mystring&quot;) );
  }
 }

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  SampleHandler handler = new SampleHandler(this);

  Intent intent = new Intent(this, HelloIntentService.class);
  intent.putExtra(&quot;messenger&quot;, new Messenger(handler));
  startService(intent);
 }
}

&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;

public class HelloIntentService extends IntentService {

 private static final String TAG = &quot;HelloIntentService&quot;;

 public HelloIntentService() {
  super(&quot;HelloIntentService&quot;);

  Log.v(TAG, &quot;HelloIntentService&quot;);
 }

 @Override
 protected void onHandleIntent(Intent intent) {
  Log.v(TAG, &quot;onHandleIntent&quot;);

  Bundle bundle = intent.getExtras();
  if (bundle != null) {
   Messenger messenger = (Messenger) bundle.get(&quot;messenger&quot;);
   Message msg = Message.obtain();
   
   Bundle data = new Bundle();
   data.putString(&quot;mystring&quot;, &quot;Hello!&quot;);
   msg.setData(data);
   try {
    messenger.send(msg);
   } catch (RemoteException e) {
    Log.i(&quot;error&quot;, &quot;error&quot;);
   }
  }
 }

 @Override
 public void onDestroy() {
  Log.v(TAG, &quot;onDestroy&quot;);
 }

}
&lt;/pre&gt;
&lt;hr /&gt;
while ループが永遠に終わらない処理の場合、&lt;br /&gt;
呼び出し元のアクティビティーが終了しても、動き続けるので、&lt;br /&gt;
IntentServiceを終了させる処理が必要なようです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX14qlENc-RlFG3ScCDAw57dHnU5jHc97nR3uGvek1vcHeSuWMkycXqjlHcBXEPhuR5yF_PdDOsX7ROHuBctjL_eYKMT6UOZ4J1eHvVpoedLJW94hr_2Sgs52GEeF-BVjmUXuzONJrGFUq/s1600/141.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX14qlENc-RlFG3ScCDAw57dHnU5jHc97nR3uGvek1vcHeSuWMkycXqjlHcBXEPhuR5yF_PdDOsX7ROHuBctjL_eYKMT6UOZ4J1eHvVpoedLJW94hr_2Sgs52GEeF-BVjmUXuzONJrGFUq/s1600/141.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.widget.TextView;

public class MainActivity extends Activity {

 public static class SampleHandler extends Handler {
  private MainActivity con;

  public SampleHandler(MainActivity mainActivity) {
   // TODO 自動生成されたコンストラクター・スタブ
   this.con = mainActivity;
  }

  @Override
  public void handleMessage(Message msg) {
   Bundle bundle = msg.getData();

   TextView textView = (TextView) con.findViewById(R.id.textView1);
   textView.setText(bundle.getString(&quot;mystring&quot;));
  }
 }

 private SampleHandler handler;
 private Intent intent;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  handler = new SampleHandler(this);

  intent = new Intent(this, HelloIntentService.class);
  intent.putExtra(&quot;messenger&quot;, new Messenger(handler));
  startService(intent);
 }

 @Override
 public void onDestroy() {
  super.onDestroy();
  // The service is no longer used and is being destroyed

  if (intent != null) {
   stopService(intent);
   intent = null;
  }
 }
}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.intentservice;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;

public class HelloIntentService extends IntentService {

 private static final String TAG = &quot;HelloIntentService&quot;;
 private boolean loopFlag = true;

 public HelloIntentService() {
  super(&quot;HelloIntentService&quot;);

  Log.v(TAG, &quot;HelloIntentService&quot;);

 }

 @Override
 protected void onHandleIntent(Intent intent) {
  Log.v(TAG, &quot;onHandleIntent&quot;);

  Bundle bundle = intent.getExtras();

  while (loopFlag) {
   synchronized (this) {
    try {
     Log.v(TAG, &quot;HelloIntentService&quot;);
     GregorianCalendar gc = (GregorianCalendar) GregorianCalendar.getInstance(TimeZone.getTimeZone(&quot;Asia/Tokyo&quot;));
     String stringTime = gc.get(Calendar.HOUR_OF_DAY) + &quot;:&quot; + gc.get(Calendar.MINUTE) + &quot;:&quot; + gc.get(Calendar.SECOND);

     if (bundle != null) {
      Messenger messenger = (Messenger) bundle.get(&quot;messenger&quot;);
      Message msg = Message.obtain();

      Bundle data = new Bundle();

      data.putString(&quot;mystring&quot;, stringTime);
      msg.setData(data);
      try {
       messenger.send(msg);
      } catch (RemoteException e) {
       Log.i(&quot;error&quot;, &quot;error&quot;);
      }
     }

     wait(1000);
    } catch (Exception e) {
    }
   }
  }

 }

 @Override
 public void onDestroy() {
  Log.v(TAG, &quot;onDestroy&quot;);
  loopFlag = false;
 }

}
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/2540833227858995760/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/intentservice-an.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2540833227858995760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2540833227858995760'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/intentservice-an.html' title='IntentService を使ってみる：android'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX14qlENc-RlFG3ScCDAw57dHnU5jHc97nR3uGvek1vcHeSuWMkycXqjlHcBXEPhuR5yF_PdDOsX7ROHuBctjL_eYKMT6UOZ4J1eHvVpoedLJW94hr_2Sgs52GEeF-BVjmUXuzONJrGFUq/s72-c/141.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-542936080208447497</id><published>2013-10-05T15:12:00.004+09:00</published><updated>2013-10-08T10:49:48.582+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Service と BroadcastReceiver :android</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr5qP89N9dsBGfwSCAc5ftk3EURnJQK7rgsApQcdJpyuaIl8DLBSsE4Ntx8tjggWqh0dTExfoUN3nonC5bIHQ_etfWeD_Es1mZdxtL8PCl-I4j5sKi3DS9hDlAAuG1-xzRpogUe8v5md5n/s1600/140.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr5qP89N9dsBGfwSCAc5ftk3EURnJQK7rgsApQcdJpyuaIl8DLBSsE4Ntx8tjggWqh0dTExfoUN3nonC5bIHQ_etfWeD_Es1mZdxtL8PCl-I4j5sKi3DS9hDlAAuG1-xzRpogUe8v5md5n/s1600/140.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Activity で　レシーバーを登録して、インテントでサービスを開始する。&lt;br /&gt;
&lt;br /&gt;
サービスでは、システムの時間を取得して、レシーバーに送る。&lt;br /&gt;
&lt;br /&gt;
レシーバーでは受っとった時間を画面に表示する。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.servicetest;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {
 IntentFilter intentFilter;
 MyService4Receiver receiver;
 Intent intent = null;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  // レシーバーの登録
  receiver = new MyService4Receiver();
  receiver.activity = this;
  intentFilter = new IntentFilter();
  intentFilter.addAction(MyService4Service.actionName);
  registerReceiver(receiver, intentFilter);
 }
 
 public void onResume() {
  super.onResume();
  Log.i(&quot;タグ&quot;, &quot;onResume()&quot;);

  intent = new Intent(getBaseContext(), MyService4Service.class);
  startService(intent);
 }
 
 public void onDestroy() {
  super.onDestroy();
  Log.i(&quot;タグ&quot;, &quot;onDestroy()&quot;);
  
  unregisterReceiver(receiver);//レシーバー登録解除
  
  if (intent != null)
  {
   stopService(intent);//サービスの停止
  }
  intent = null;

 }

}

&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.servicetest;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;

public class MyService4Service extends Service {
 public static final String actionName = &quot;MYSERVICE4_ACTION&quot;;
 MyHandler mHandler = null;
 private static Context contex;

 @Override
 public int onStartCommand(Intent intent, int flags, int startId) {
  Log.i(&quot;MyService4Service&quot;, &quot;onStartCommand&quot;);

  if (mHandler == null)
  {
   mHandler = new MyHandler();
   mHandler.sendEmptyMessage(1);
  }
  
  contex = getBaseContext();

  return START_NOT_STICKY;//サービスの強制終了後、再起動しない
 }

 public void onDestroy()
 {
  if (mHandler != null)
  {
   mHandler.removeMessages(1);
   mHandler = null;
  }
  super.onDestroy();
 }

 @Override
 public IBinder onBind(Intent arg0) {
  // TODO 自動生成されたメソッド・スタブ
  return null;
 }

 static class MyHandler extends Handler
 {
  public void handleMessage(Message msg)
  {
   GregorianCalendar gc = (GregorianCalendar) GregorianCalendar.getInstance(TimeZone.getTimeZone(&quot;Asia/Tokyo&quot;));
   String stringTime = gc.get(Calendar.HOUR_OF_DAY) + &quot;:&quot; + gc.get(Calendar.MINUTE) + &quot;:&quot; + gc.get(Calendar.SECOND);

   Intent broadcastIntent = new Intent();
   broadcastIntent.putExtra(&quot;message&quot;, stringTime);
   broadcastIntent.setAction(actionName);
   contex.sendBroadcast(broadcastIntent);

   sendEmptyMessageDelayed(1, 1000);
  }
 }
}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.servicetest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MyService4Receiver extends BroadcastReceiver {
 MainActivity activity;// onCreate の　receiver.activity = this;


 @Override
 public void onReceive(Context context, Intent intent) {
  // メッセージを取ってくる
  
  Log.i(&quot;MyService4Receiver&quot;, &quot;onReceive&quot;);
  
  Bundle bundle = intent.getExtras();
  String message = bundle.getString(&quot;message&quot;);
  // そいつを表示する
  if (activity != null)
  {
   TextView tv = (TextView) activity.findViewById(R.id.textView1);
   tv.setText(message);
  }
 }
}
&lt;/pre&gt;
&lt;br /&gt;
サービスはマニフェストにも登録しておく、&lt;br /&gt;
レシーバはregisterReceiver（）；で動的に登録してあるので、マニフェストには登録しなくても動く。</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/542936080208447497/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/service-broadcastreceiver-android.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/542936080208447497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/542936080208447497'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/service-broadcastreceiver-android.html' title='Service と BroadcastReceiver :android'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr5qP89N9dsBGfwSCAc5ftk3EURnJQK7rgsApQcdJpyuaIl8DLBSsE4Ntx8tjggWqh0dTExfoUN3nonC5bIHQ_etfWeD_Es1mZdxtL8PCl-I4j5sKi3DS9hDlAAuG1-xzRpogUe8v5md5n/s72-c/140.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-3576960567556882838</id><published>2013-10-04T13:15:00.000+09:00</published><updated>2013-10-04T15:40:16.201+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Service"/><title type='text'>サービスのバインドについて考えてみる</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijMoy3SvKCK8pyOYy85Opvh5GhKXwQwCPdgJ1N-q7QQjquDeysusbTSRIQGqYJtpA12buVawIepE79U9L2GCj24QxViqQgSSYbIk6LuNzikwPC0zXOJjeDbhACdUTGlsQGPTIpR6DueO1y/s1600/137.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijMoy3SvKCK8pyOYy85Opvh5GhKXwQwCPdgJ1N-q7QQjquDeysusbTSRIQGqYJtpA12buVawIepE79U9L2GCj24QxViqQgSSYbIk6LuNzikwPC0zXOJjeDbhACdUTGlsQGPTIpR6DueO1y/s1600/137.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
サービスをバインドして、サービスからＵＩを変更&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.widget.TextView;

import com.example.bindservice.SampleService.LocalBinder;

public class MainActivity extends Activity {

 private static final String TAB = &quot;MainActivity&quot;;
 private TextView tv;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  tv = (TextView) findViewById(R.id.textView1);

 }

 @Override
 public void onStart() {
  Log.i(TAB, &quot;onStart&quot;);
  super.onStart();
  // Bind
  Intent intent = new Intent(getApplicationContext(), SampleService.class);
  bindService(intent, mySrviceConnection, Context.BIND_AUTO_CREATE);//サービスをバインド
 }

 @Override
 public void onStop() {
  Log.i(TAB, &quot;onStop&quot;);
  super.onStop();
  // Unbind
  unbindService(mySrviceConnection);//サービスをアンバインド
 }

 private ServiceConnection mySrviceConnection = new ServiceConnection() {

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
   LocalBinder binder = (SampleService.LocalBinder) service;
   binder.getService(tv);
  }

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO 自動生成されたメソッド・スタブ

  }
 };

}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.TextView;

public class SampleService extends Service {

 private static final String TAB = &quot;SampleService&quot;;
 private IBinder mBinder = new LocalBinder();

 public class LocalBinder extends Binder {
        SampleService getService(TextView tv) {
      Log.i(TAB, &quot;LocalBinder&quot;);//
      tv.setText(&quot;サービスから変更&quot;);
            return SampleService.this;
        }
    }

 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAB, &quot;onBind&quot;);//起動時に呼ばれる

  return mBinder;
 }

 @Override
 public void onDestroy() {
  Log.i(TAB, &quot;onDestroy&quot;);
 }
}
&lt;/pre&gt;
&lt;hr /&gt;
ボタンクリックでＵＩを変更してみる&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.bindservice.SampleService.LocalBinder;

public class MainActivity extends Activity {

 private static final String TAB = &quot;MainActivity&quot;;
 private TextView tv;
 private LocalBinder binder;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  tv = (TextView) findViewById(R.id.textView1);

  Button button = (Button) findViewById(R.id.button1);
  button.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    Log.i(TAB, &quot;ボタン２が押された&quot;);
    if (binder != null){
     Log.i(TAB, &quot;binder は　null で無い&quot;);
     binder.getService(tv);
    }else{
     Log.i(TAB, &quot;binder は　null&quot;);
    }
   }
  });
 }

 @Override
 public void onStart() {
  Log.i(TAB, &quot;onStart&quot;);
  super.onStart();
  // Bind
  Intent intent = new Intent(getApplicationContext(), SampleService.class);
  bindService(intent, mySrviceConnection, Context.BIND_AUTO_CREATE);//サービスをバインド
 }

 @Override
 public void onStop() {
  Log.i(TAB, &quot;onStop&quot;);
  super.onStop();
  // Unbind
  unbindService(mySrviceConnection);//サービスをアンバインド
 }

 private ServiceConnection mySrviceConnection = new ServiceConnection() {

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
   binder = (SampleService.LocalBinder) service;
  }

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO 自動生成されたメソッド・スタブ

  }
 };

}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.TextView;

public class SampleService extends Service {

 private static final String TAB = &quot;SampleService&quot;;
 private IBinder mBinder = new LocalBinder();

 public class LocalBinder extends Binder {
  void getService(TextView tv) {
   Log.i(TAB, &quot;LocalBinder&quot;);//
   tv.setText(&quot;サービスから変更&quot;);
  }
 }

 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAB, &quot;onBind&quot;);//起動時に呼ばれる

  return mBinder;
 }

 @Override
 public void onDestroy() {
  Log.i(TAB, &quot;onDestroy&quot;);
 }
}
&lt;/pre&gt;
&lt;hr /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qAVSRvopq3wown7Ux0gVFNxjVUe4bVFq3I3A8PUBKkKBerTXk5T3EM9LvBvM8hIHzhQVvJSyIFIA_MoOFFY-pqq9Bwa9bV927olKfc5nofeUCSAeOoMzJjBgrNOf9zseO7TlSnzRdDtl/s1600/138.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qAVSRvopq3wown7Ux0gVFNxjVUe4bVFq3I3A8PUBKkKBerTXk5T3EM9LvBvM8hIHzhQVvJSyIFIA_MoOFFY-pqq9Bwa9bV927olKfc5nofeUCSAeOoMzJjBgrNOf9zseO7TlSnzRdDtl/s1600/138.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
サービスでスレッドを利用して定期的にＵＩを更新
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.bindservice.SampleService.LocalBinder;

public class MainActivity extends Activity {

 private static final String TAB = &quot;MainActivity&quot;;
 private TextView tv;
 private LocalBinder binder;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  tv = (TextView) findViewById(R.id.textView1);

  Button button = (Button) findViewById(R.id.button1);
  button.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    Log.i(TAB, &quot;ボタン２が押された&quot;);
    if (binder != null){
     Log.i(TAB, &quot;binder は　null ではない&quot;);
     binder.getService(tv);
    }else{
     Log.i(TAB, &quot;binder は　null&quot;);
    }
   }
  });
 }

 @Override
 public void onStart() {
  Log.i(TAB, &quot;onStart&quot;);
  super.onStart();
  // Bind
  Intent intent = new Intent(getApplicationContext(), SampleService.class);
  bindService(intent, mySrviceConnection, Context.BIND_AUTO_CREATE);//サービスをバインド
 }

 @Override
 public void onStop() {
  Log.i(TAB, &quot;onStop&quot;);
  super.onStop();
  // Unbind
  unbindService(mySrviceConnection);//サービスをアンバインド
 }

 private ServiceConnection mySrviceConnection = new ServiceConnection() {

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
   binder = (SampleService.LocalBinder) service;
  }

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO 自動生成されたメソッド・スタブ

  }
 };

}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;

public class SampleService extends Service {

 private Handler handler;

 public class MyThread implements Runnable {

  private int data;

  @Override
  public void run() {
   // TODO 自動生成されたメソッド・スタブ
   while (true) {
    Log.i(TAB, &quot;run::&quot; + data);//二番目に呼ばれる

    data++;
    Message msg = handler.obtainMessage();
    msg.arg1 = data;
    handler.sendMessage(msg);
    try {
     Thread.sleep(2000);
    } catch (InterruptedException e) {
     // TODO 自動生成された catch ブロック
     e.printStackTrace();
    }
   }
  }

 }

 private static final String TAB = &quot;SampleService&quot;;
 private IBinder mBinder = new LocalBinder();

 public class LocalBinder extends Binder {

  void getService(final TextView tv) {
   Log.i(TAB, &quot;LocalBinder&quot;);//
   //tv.setText(&quot;setData から変更&quot;);//ここでも変更可能

   new Thread(new MyThread()).start();

   /*
   //動くがメモリーリークの可能性がある
   //This Handler class should be static or leaks might occur
   handler = new Handler() {
    public void handleMessage(Message msg) {
     //updata.update(tv, data);
     Log.i(TAB, &quot;handleMessage::&quot; + msg);

     tv.setText(String.valueOf(msg.arg1));//ここでも変更可能

    }
   };
   */
   handler = new MyHandler(tv);
  }
 }

 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAB, &quot;onBind&quot;);//起動時に呼ばれる

  return mBinder;
 }

 @Override
 public void onDestroy() {
  Log.i(TAB, &quot;onDestroy&quot;);
 }

 public static class MyHandler extends Handler {
  private TextView tv;

  public MyHandler(TextView tv) {
   // TODO 自動生成されたコンストラクター・スタブ
   this.tv = tv;
  }

  @Override
  public void handleMessage(Message msg) {
   Log.i(TAB, &quot;handleMessage::&quot; + msg);
   tv.setText(String.valueOf(msg.arg1));//ここでも変更可能
  }

 }
}
&lt;/pre&gt;
&lt;hr /&gt;
サービスで変更された値をアクティビティに戻してＵＩを変更する。&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.bindservice.SampleService.LocalBinder;
import com.example.bindservice.SampleService.UpdateData;

public class MainActivity extends Activity {

 private static final String TAB = &quot;MainActivity&quot;;
 private TextView tv;
 private LocalBinder binder;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  tv = (TextView) findViewById(R.id.textView1);

  Button button = (Button) findViewById(R.id.button1);
  button.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    Log.i(TAB, &quot;ボタン２が押された&quot;);
    if (binder != null) {
     Log.i(TAB, &quot;binder は　null ではない&quot;);
     binder.getService(new UpdateData() {

      @Override
      public void update(int data) {
       // TODO 自動生成されたメソッド・スタブ
       tv.setText(data + &quot;&quot;);
      }
     });

    } else {
     Log.i(TAB, &quot;binder は　null&quot;);
    }
   }
  });
 }

 @Override
 public void onStart() {
  Log.i(TAB, &quot;onStart&quot;);
  super.onStart();
  // Bind
  Intent intent = new Intent(getApplicationContext(), SampleService.class);
  bindService(intent, mySrviceConnection, Context.BIND_AUTO_CREATE);//サービスをバインド
 }

 @Override
 public void onStop() {
  Log.i(TAB, &quot;onStop&quot;);
  super.onStop();
  // Unbind
  unbindService(mySrviceConnection);//サービスをアンバインド
 }

 private ServiceConnection mySrviceConnection = new ServiceConnection() {

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
   binder = (SampleService.LocalBinder) service;
  }

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO 自動生成されたメソッド・スタブ

  }
 };

}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.bindservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;

public class SampleService extends Service {

 public interface UpdateData {
  public void update(int data);
 }

 private Handler handler;

 public class MyThread implements Runnable {

  private int data;

  @Override
  public void run() {
   // TODO 自動生成されたメソッド・スタブ
   while (true) {
    Log.i(TAB, &quot;run::&quot; + data);//二番目に呼ばれる

    data++;
    Message msg = handler.obtainMessage();
    msg.arg1 = data;
    handler.sendMessage(msg);
    try {
     Thread.sleep(2000);
    } catch (InterruptedException e) {
     // TODO 自動生成された catch ブロック
     e.printStackTrace();
    }
   }
  }

 }

 private static final String TAB = &quot;SampleService&quot;;
 private IBinder mBinder = new LocalBinder();

 public class LocalBinder extends Binder {

  void getService(UpdateData updata) {
   Log.i(TAB, &quot;LocalBinder&quot;);//
   //tv.setText(&quot;setData から変更&quot;);//ここでも変更可能

   new Thread(new MyThread()).start();

   handler = new MyHandler(updata);
  }
 }

 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAB, &quot;onBind&quot;);//起動時に呼ばれる

  return mBinder;
 }

 @Override
 public void onDestroy() {
  Log.i(TAB, &quot;onDestroy&quot;);
 }

 public static class MyHandler extends Handler {
  private UpdateData updata;

  public MyHandler(UpdateData updata) {
   // TODO 自動生成されたコンストラクター・スタブ
   //this.tv = tv;
   this.updata = updata;
  }

  @Override
  public void handleMessage(Message msg) {
   Log.i(TAB, &quot;handleMessage::&quot; + msg);
   //tv.setText(String.valueOf(msg.arg1));//ここでも変更可能
   updata.update(msg.arg1);
  }

 }
}
&lt;/pre&gt;
&lt;hr /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNEUzwFFJG5d0VIv_KbNvRPWbtBETR7ACDeE5LwVYJIXIGbcVo5hWc3rAvpcls9f0KxfLnGft7uuUrrK-NSBdHEChl4DWGefBEzYwESri_-5UVWGq9B1p7fk0SEYDoQAUvJaIaOCfGRvDZ/s1600/139.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNEUzwFFJG5d0VIv_KbNvRPWbtBETR7ACDeE5LwVYJIXIGbcVo5hWc3rAvpcls9f0KxfLnGft7uuUrrK-NSBdHEChl4DWGefBEzYwESri_-5UVWGq9B1p7fk0SEYDoQAUvJaIaOCfGRvDZ/s1600/139.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
時間を表示してみる。&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
package com.example.bindservice;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.bindservice.SampleService.LocalBinder;
import com.example.bindservice.SampleService.UpdateData;

public class MainActivity extends Activity {

 private static final String TAB = &quot;MainActivity&quot;;
 private TextView tv;
 private LocalBinder binder;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  tv = (TextView) findViewById(R.id.textView1);

  Button button = (Button) findViewById(R.id.button1);
  button.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    Log.i(TAB, &quot;ボタン２が押された&quot;);
    if (binder != null) {
     Log.i(TAB, &quot;binder は　null ではない&quot;);
     binder.getService(new UpdateData() {

      @Override
      public void update(String data) {
       // TODO 自動生成されたメソッド・スタブ
       tv.setText(data + &quot;&quot;);
      }
     });

    } else {
     Log.i(TAB, &quot;binder は　null&quot;);
    }
   }
  });
 }

 @Override
 public void onStart() {
  Log.i(TAB, &quot;onStart&quot;);
  super.onStart();
  // Bind
  Intent intent = new Intent(getApplicationContext(), SampleService.class);
  bindService(intent, mySrviceConnection, Context.BIND_AUTO_CREATE);//サービスをバインド
 }

 @Override
 public void onStop() {
  Log.i(TAB, &quot;onStop&quot;);
  super.onStop();
  // Unbind
  unbindService(mySrviceConnection);//サービスをアンバインド
 }

 private ServiceConnection mySrviceConnection = new ServiceConnection() {

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
   binder = (SampleService.LocalBinder) service;
  }

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO 自動生成されたメソッド・スタブ

  }
 };

}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
package com.example.bindservice;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;

public class SampleService extends Service {

 public interface UpdateData {
  public void update(String data);
 }

 private static final String TAB = &quot;SampleService&quot;;
 private IBinder mBinder = new LocalBinder();

 public class LocalBinder extends Binder {

  void getService(UpdateData updata) {
   Log.i(TAB, &quot;LocalBinder&quot;);//
   //tv.setText(&quot;setData から変更&quot;);//ここでも変更可能

   //new Thread(new MyThread()).start();

   MyHandler handler = new MyHandler(updata);
   handler.sendEmptyMessage(1);
  }
 }

 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAB, &quot;onBind&quot;);//起動時に呼ばれる

  return mBinder;
 }

 @Override
 public void onDestroy() {
  Log.i(TAB, &quot;onDestroy&quot;);
 }

 public static class MyHandler extends Handler {
  private UpdateData updata;

  public MyHandler(UpdateData updata) {
   // TODO 自動生成されたコンストラクター・スタブ
   //this.tv = tv;
   this.updata = updata;
  }

  @Override
  public void handleMessage(Message msg) {
   Log.i(TAB, &quot;handleMessage::&quot; + msg);

   GregorianCalendar gc = (GregorianCalendar) GregorianCalendar.getInstance(TimeZone.getTimeZone(&quot;Asia/Tokyo&quot;));
   String data = gc.get(Calendar.HOUR_OF_DAY) + &quot;:&quot; + gc.get(Calendar.MINUTE) + &quot;:&quot; + gc.get(Calendar.SECOND);

   sendEmptyMessageDelayed(1, 1000);
   
   updata.update(data);
  }

 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/3576960567556882838/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3576960567556882838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3576960567556882838'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/10/blog-post.html' title='サービスのバインドについて考えてみる'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijMoy3SvKCK8pyOYy85Opvh5GhKXwQwCPdgJ1N-q7QQjquDeysusbTSRIQGqYJtpA12buVawIepE79U9L2GCj24QxViqQgSSYbIk6LuNzikwPC0zXOJjeDbhACdUTGlsQGPTIpR6DueO1y/s72-c/137.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-8675453841303384338</id><published>2013-09-24T09:09:00.004+09:00</published><updated>2013-09-24T09:18:27.596+09:00</updated><title type='text'>キャッチされなかった例外が発生した場合の処理：Android UncaughtExceptionHandler</title><content type='html'>&lt;br /&gt;
キャッチされなかった例外が発生した場合、アプリを再起動させる。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.exceptionchach;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {

 protected static final String TAG = &quot;123&quot;;

 private MainActivity activityMain;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  activityMain = this;

  //キャッチされない例外により、スレッドが突然終了したときや、  
  //このスレッドに対してほかにハンドラが定義されていないときに  
  //呼び出されるデフォルトのハンドラを設定します。  
  Thread.setDefaultUncaughtExceptionHandler(new CsUncaughtExceptionHandler(activityMain));

  findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    // 例外を発生させる
    throw new IllegalStateException();
   }
  });
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.exceptionchach;

import java.lang.Thread.UncaughtExceptionHandler;

import android.content.Intent;
import android.util.Log;

public class CsUncaughtExceptionHandler implements UncaughtExceptionHandler {

 private static final String TAG = &quot;CsUncaughtExceptionHandler&quot;;

 // 現在設定されている UncaughtExceptionHandler を退避
 final UncaughtExceptionHandler savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();

 private MainActivity myContext;

 public CsUncaughtExceptionHandler(MainActivity context) {
  // TODO 自動生成されたコンストラクター・スタブ
  myContext = context;
 }

 /*
  * キャッチされない例外によって指定されたスレッドが終了したときに呼び出されます 
  */
 @Override
 public void uncaughtException(Thread thread, Throwable exception) {
  // TODO 自動生成されたメソッド・スタブ
  Log.d(TAG, &quot;uncaughtException&quot;);

  // catchされなかった例外処理 エラーログを保存したりする。

  // 退避しておいた UncaughtExceptionHandler を実行
  //savedUncaughtExceptionHandler.uncaughtException(thread, ex);//例外のダイアログ表示

  //再起動処理
  Intent in = new Intent(myContext, MainActivity.class);
  myContext.startActivity(in);

  myContext.finish();
  android.os.Process.killProcess(android.os.Process.myPid());

 }

}
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/8675453841303384338/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-uncaughtexceptionhandler.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8675453841303384338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8675453841303384338'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-uncaughtexceptionhandler.html' title='キャッチされなかった例外が発生した場合の処理：Android UncaughtExceptionHandler'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-5772695050792305896</id><published>2013-09-20T16:54:00.002+09:00</published><updated>2013-09-20T16:54:16.258+09:00</updated><title type='text'>PreferenceActivityのdeprecation対策</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgImvsLTxOELJlMwfEMQVTroy3bszhmgH2jPqbGrYA4IF93k09Wn8Xfrar-aNFnt-jmHMsOrordFuH6hDznPrV5FshF1_FMp2NYZMyn1HK8g5zZYNixm-r7yk8Jz-jQNhMETVQLkBq9XfXp/s1600/device-2013-09-20-165154.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgImvsLTxOELJlMwfEMQVTroy3bszhmgH2jPqbGrYA4IF93k09Wn8Xfrar-aNFnt-jmHMsOrordFuH6hDznPrV5FshF1_FMp2NYZMyn1HK8g5zZYNixm-r7yk8Jz-jQNhMETVQLkBq9XfXp/s320/device-2013-09-20-165154.png&quot; width=&quot;177&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
package com.example.preferencetest;

import android.annotation.TargetApi;
import android.os.Bundle;
import android.os.Build;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;

public class Pref extends PreferenceActivity {

 @TargetApi(11)
 public class prefFragment extends PreferenceFragment  {
  @Override
  public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   
      addPreferencesFromResource(R.xml.preferences);
  }

 }
 @TargetApi(11)
 @SuppressWarnings(&quot;deprecation&quot;)
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // version3.0 より前 
  if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.HONEYCOMB) {
   addPreferencesFromResource(R.xml.preferences);
        
  } else {
   // version3.0 以降
   getFragmentManager().beginTransaction().replace(android.R.id.content, new prefFragment()).commit();
  }
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/5772695050792305896/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/preferenceactivitydeprecation.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5772695050792305896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5772695050792305896'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/preferenceactivitydeprecation.html' title='PreferenceActivityのdeprecation対策'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgImvsLTxOELJlMwfEMQVTroy3bszhmgH2jPqbGrYA4IF93k09Wn8Xfrar-aNFnt-jmHMsOrordFuH6hDznPrV5FshF1_FMp2NYZMyn1HK8g5zZYNixm-r7yk8Jz-jQNhMETVQLkBq9XfXp/s72-c/device-2013-09-20-165154.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-5848407941600925864</id><published>2013-09-16T18:10:00.001+09:00</published><updated>2013-10-05T09:17:00.323+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GPS"/><title type='text'>別スレッドで位置情報を取得する：Android GPS Looper</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
package com.example.gpsintent2;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends Activity {

 private MyLocThread thread1;
 private TextView textView;
 private Handler viewHandler;
 private static final String TAG = &quot;********************&quot;;

 public class MyLocThread extends Thread  {

  private LocationManager locationManager;

  private LocationHelper loc;
  private Handler handler;
  

  public MyLocThread() {
   Log.v(TAG, &quot;------MyLocThread----&quot;);

   setDaemon(true);
   setName(&quot;LocationThread&quot;);
   locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   
   loc = new LocationHelper(  );
   

  }

  public void run() {
   Log.v(TAG, &quot;------run----&quot;);
   
   Looper.prepare();
   handler = new Handler();
   locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 0f, loc );
   Looper.loop();

  }

  private void StopRequest() {
   // TODO 自動生成されたメソッド・スタブ
   if( locationManager != null){
    locationManager.removeUpdates(loc);
   }
   
   if ( this.handler != null ){
    Log.i(TAG, &quot;looper　と　handler　停止処理&quot;);
    
    this.handler.getLooper().quit();
    this.handler  = null;
    
   }
  }
 }

 public class LocationHelper implements LocationListener {

  private Location loc;

  @Override
  public void onLocationChanged(Location location) {
   // TODO 自動生成されたメソッド・スタブ
   Log.v(TAG, &quot;onLocationChanged&quot;);
   
   loc = location;

   viewHandler.post(new Runnable() {
    public void run() {
     textView.setText( &quot;緯度&quot; + loc.getLatitude() );
    }
   });

   Log.i(&quot;Latitude&quot;, String.valueOf(location.getLatitude()));
   Log.i(&quot;Longitude&quot;, String.valueOf(location.getLongitude()));
   Log.i(&quot;Accuracy&quot;, String.valueOf(location.getAccuracy()));
   Log.i(&quot;Altitude&quot;, String.valueOf(location.getAltitude()));
   Log.i(&quot;Time&quot;, String.valueOf(location.getTime()));
   Log.i(&quot;Speed&quot;, String.valueOf(location.getSpeed()));
   Log.i(&quot;Bearing&quot;, String.valueOf(location.getBearing()));
  }

  @Override
  public void onProviderDisabled(String arg0) {
   // TODO 自動生成されたメソッド・スタブ
   Log.v(TAG, &quot;onProviderDisabled&quot;);
  }

  @Override
  public void onProviderEnabled(String arg0) {
   // TODO 自動生成されたメソッド・スタブ
   Log.v(TAG, &quot;onProviderEnabled&quot;);
  }

  @Override
  public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
   // TODO 自動生成されたメソッド・スタブ
   Log.v(TAG, &quot;onStatusChanged&quot;);
  }

 }

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  textView = (TextView) findViewById(R.id.textView1);
  
  //UI を変更したい場合必要
  viewHandler = new Handler();

 }

 @Override
 protected void onResume() {
  super.onResume();

  Log.i(TAG, &quot;onResume&quot;);

  thread1 = new MyLocThread();
  thread1.start();

 }

 @Override
 protected void onPause() {
  super.onPause();

  Log.i(TAG, &quot;onPause&quot;);
  
  // 便宜的にここで停止処理
  thread1.StopRequest();

 }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/5848407941600925864/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-gps.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5848407941600925864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/5848407941600925864'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-gps.html' title='別スレッドで位置情報を取得する：Android GPS Looper'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-8569772372260940034</id><published>2013-09-16T14:09:00.000+09:00</published><updated>2013-09-25T06:11:16.868+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GPS"/><title type='text'>AVDに位置情報を送る：Android gps</title><content type='html'>エミュレータに位置情報を送るのに、苦労したのでメモしておく。&lt;br /&gt;
&lt;br /&gt;
&lt;strike&gt;結論はAVDのターゲットをGoogle APIs　にする。
&lt;/strike&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi67XHal_0rwhyphenhyphenGR2glKObeOn9bK9esm6ooJJZCsm3cAL_vgVVVAcMeOdM2_Fo91DcddLwoPwrWCVMM_Q9bX3jSJInx13Zg8v6q-JCBfEi8q-W7eHQyMHwFEsRpqHjk4O2rAODvDv4hBY5/s1600/133.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi67XHal_0rwhyphenhyphenGR2glKObeOn9bK9esm6ooJJZCsm3cAL_vgVVVAcMeOdM2_Fo91DcddLwoPwrWCVMM_Q9bX3jSJInx13Zg8v6q-JCBfEi8q-W7eHQyMHwFEsRpqHjk4O2rAODvDv4hBY5/s320/133.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
ターゲットに選択肢が出ない場合は、Android SDK Manager を起動させてダウンロードしておく。&lt;br /&gt;
&lt;br /&gt;
あとは、DDMSパースペクティブ　のエミュレーター制御から、&lt;br /&gt;
Location Controls の送信ボタンを押す。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC6rJLalyzNwA1uf0BLSzgTajAoMxx3oD2hExustLzoITNKxvXljKOvG6-lDPGVLGIb9OZMC1dGKEhqjYrIcwltm8uvmKxxW1XQEgEMbR_IeazWalyt7t3UjauhcxC_V41Mo46yjr1gGQM/s1600/134.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC6rJLalyzNwA1uf0BLSzgTajAoMxx3oD2hExustLzoITNKxvXljKOvG6-lDPGVLGIb9OZMC1dGKEhqjYrIcwltm8uvmKxxW1XQEgEMbR_IeazWalyt7t3UjauhcxC_V41Mo46yjr1gGQM/s320/134.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpOVGNJkDTbuAdwsMWbgs_Dz4xt8A3D7IPJyXF3pHl4XGvIgNrZvapkTf-_uZA6DRPMcpyjRPVTMqIoXj_OaC8aKosOEer0fmAmFbHrBwGt_Ty0XnRltEji8SoOR5X9AbHxiMX9AzPi3C9/s1600/135.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpOVGNJkDTbuAdwsMWbgs_Dz4xt8A3D7IPJyXF3pHl4XGvIgNrZvapkTf-_uZA6DRPMcpyjRPVTMqIoXj_OaC8aKosOEer0fmAmFbHrBwGt_Ty0XnRltEji8SoOR5X9AbHxiMX9AzPi3C9/s1600/135.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
端数に違いが？&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
その他：&lt;br /&gt;
プログラムでは、GPS_PROVIDER を使う。&lt;br /&gt;
マニフェストにも、&amp;lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot;/&amp;gt;　の許可を与える。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/8569772372260940034/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/avdandroid-gps.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8569772372260940034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8569772372260940034'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/avdandroid-gps.html' title='AVDに位置情報を送る：Android gps'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi67XHal_0rwhyphenhyphenGR2glKObeOn9bK9esm6ooJJZCsm3cAL_vgVVVAcMeOdM2_Fo91DcddLwoPwrWCVMM_Q9bX3jSJInx13Zg8v6q-JCBfEi8q-W7eHQyMHwFEsRpqHjk4O2rAODvDv4hBY5/s72-c/133.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-2374946666140814896</id><published>2013-09-15T07:33:00.003+09:00</published><updated>2013-09-15T07:53:04.626+09:00</updated><title type='text'>BroadcastReceiver を使って位置情報取得 エンクロージング：GPS</title><content type='html'>&lt;pre class=&quot;brush: java;&quot;&gt;BroadcastReceiver はプログラムから登録しているのでマニフェストでは指定していない。&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4elo4i6t9EhA3LaYr33Z-0sjTniA0QC-l5tlD8vYBHyrq8TDmOM-MlYrqSq1WM0WhL5S9ao776EIdjOLV54QpHacvOZVZ-XTCgcVGLM3HnsGjftaE14bJiYPO64PC9AnhOq4QymA8RlDJ/s1600/132.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4elo4i6t9EhA3LaYr33Z-0sjTniA0QC-l5tlD8vYBHyrq8TDmOM-MlYrqSq1WM0WhL5S9ao776EIdjOLV54QpHacvOZVZ-XTCgcVGLM3HnsGjftaE14bJiYPO64PC9AnhOq4QymA8RlDJ/s320/132.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.gpsintent2;

import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends Activity {

 private static final String TAG = &quot;MainActivity&quot;;
 private static final String ACTION_LOCATION_UPDATE = &quot;com.android.practice.ACTION_LOCATION_UPDATE&quot;;
 private LocationManager locationManager;
 private PendingIntent pendingIntent;
 private LocationUpdateReceiver receiv;
 
 public class LocationUpdateReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {
   // TODO 自動生成されたメソッド・スタブ
   Log.i(TAG, &quot;onReceive&quot;);

   String action = intent.getAction();

   if (action != null &amp;amp;&amp;amp; action.equals(ACTION_LOCATION_UPDATE)) {
    final Location location = (Location) intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED);
    
    if (location == null) {
     return;
    }
    updateView(location);
   }
  }

  private void updateView(Location location) {
   // TODO 自動生成されたメソッド・スタブ

   TextView textView = (TextView) findViewById(R.id.textView1);
   textView.setText(String.valueOf(location.getLatitude()));
  }

 }

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  Log.i(TAG, &quot;************** onCreate&quot;);

  locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

  IntentFilter filter = new IntentFilter();
  filter.addAction(ACTION_LOCATION_UPDATE);

  receiv = new LocationUpdateReceiver();
  registerReceiver(receiv, filter);

 }

 @Override
 protected void onResume() {
  super.onResume();

  Log.i(TAG, &quot;onResume&quot;);

  Intent intent = new Intent();
  intent.setAction(ACTION_LOCATION_UPDATE);

  pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);


  for (String providerName : locationManager.getAllProviders()) {
   if (locationManager.isProviderEnabled(providerName)) {
     Log.d(TAG, &quot;Provider: &quot; + providerName);
    // LocationManagerにPendingIntentを登録
    locationManager.requestLocationUpdates(providerName, 0, 0, pendingIntent );
   }
  }
 }

 @Override
 protected void onPause() {
  super.onPause();

  Log.i(TAG, &quot;onPause&quot;);

  unregisterReceiver(receiv);
  locationManager.removeUpdates(pendingIntent);

 }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot; &amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/textView1&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;TextView&quot; /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/2374946666140814896/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/broadcastreceiver-gps.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2374946666140814896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/2374946666140814896'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/broadcastreceiver-gps.html' title='BroadcastReceiver を使って位置情報取得 エンクロージング：GPS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4elo4i6t9EhA3LaYr33Z-0sjTniA0QC-l5tlD8vYBHyrq8TDmOM-MlYrqSq1WM0WhL5S9ao776EIdjOLV54QpHacvOZVZ-XTCgcVGLM3HnsGjftaE14bJiYPO64PC9AnhOq4QymA8RlDJ/s72-c/132.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-8468431522615716407</id><published>2013-09-05T08:10:00.000+09:00</published><updated>2013-09-05T10:14:00.256+09:00</updated><title type='text'>Android 2.x系　でタブを実現：ActionBarSherlock</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTXra1AUpic6-GuW5rC7pyG3JqsJypiQJLv0C56MF-H0amjxNgaIdxhLzGShtmz0kj-D4sJcebcdMFC8Ig3Lm2kRdkW1_bHx1uQuM_TGxo1Jp7YbJpsKI7AxHM_ERWRpBNr3MJh6b8pExk/s1600/device-2013-09-05-101223.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTXra1AUpic6-GuW5rC7pyG3JqsJypiQJLv0C56MF-H0amjxNgaIdxhLzGShtmz0kj-D4sJcebcdMFC8Ig3Lm2kRdkW1_bHx1uQuM_TGxo1Jp7YbJpsKI7AxHM_ERWRpBNr3MJh6b8pExk/s320/device-2013-09-05-101223.png&quot; width=&quot;177&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
とりあえずやってみる。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://actionbarsherlock.com/&quot;&gt;ActionBarSherlock&lt;/a&gt;　のサイトから&lt;br /&gt;
&lt;br /&gt;
JakeWharton-ActionBarSherlock-4.4.0-0-g4a79d53.zip　をダウンロードし解凍する。&lt;br /&gt;
解凍したらJakeWharton-ActionBarSherlock-5a15d92　フォルダが作成される。&lt;br /&gt;
&lt;br /&gt;
eclipse で使ええるようにする。&lt;br /&gt;
ファイル-&amp;gt;インポートを選んで、&lt;br /&gt;
ウインドウでAndroidのExisting Android Code Into Workspace を選択する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdoDBzwbOLX5CSpBmPLloYes27eUbdzrhKq1NUN10RiALo2xExdg3C83onTpbQGenIrEyUldxmKq259uv4mqg4XHN_8pMtNGLo_Gasxyu5bABUbCAxeU82OiljKKMo1cnJSh6I2WUY3EqG/s1600/124.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;237&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdoDBzwbOLX5CSpBmPLloYes27eUbdzrhKq1NUN10RiALo2xExdg3C83onTpbQGenIrEyUldxmKq259uv4mqg4XHN_8pMtNGLo_Gasxyu5bABUbCAxeU82OiljKKMo1cnJSh6I2WUY3EqG/s320/124.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
インポートするプロジェクトを選択する。&lt;br /&gt;
解凍して出来たフォルダの中にある、&lt;br /&gt;
actionbarsherlock　フォルダを選択する。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh48ihtKDx7bgAA_oNDI9B93zIxHOzf47ExdRb3Wa28-OvDjIQ396rY2tjrQqleWxpdDltgFK9eGszYwBN_93mlHqwvoD2x6FzaqqKJGVLEoWc8apPn9d7DGDudbkBv_CoSCfD03xlWsOAG/s1600/125.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;233&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh48ihtKDx7bgAA_oNDI9B93zIxHOzf47ExdRb3Wa28-OvDjIQ396rY2tjrQqleWxpdDltgFK9eGszYwBN_93mlHqwvoD2x6FzaqqKJGVLEoWc8apPn9d7DGDudbkBv_CoSCfD03xlWsOAG/s320/125.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
プロジェクトエクスプローラに読みこまれる。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcmLFXKCxcoMROEHQVvHerb5p4ULtnnqo4GMK2rT41a_UKy0ynw0hK-U_xpeBO7qY-I7kSRkb-y5rt9NGCErVGjQb2injpuduiSQWVantMu0E4L4PC1HZLxLJNr6wDQM9PlC-m6KSJxGGE/s1600/126.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcmLFXKCxcoMROEHQVvHerb5p4ULtnnqo4GMK2rT41a_UKy0ynw0hK-U_xpeBO7qY-I7kSRkb-y5rt9NGCErVGjQb2injpuduiSQWVantMu0E4L4PC1HZLxLJNr6wDQM9PlC-m6KSJxGGE/s1600/126.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
ActionBarSherlock　の準備はとりあえず完了。&lt;br /&gt;
&lt;hr /&gt;
タブを使うAndroid プロジェクトを作成する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJekSt1s_qcJ5EAhpNfyHp4HqkS75YUoHWMEoTDl0GmxmJyz0Y4AOrzMIWR0R89eKYC74UEO_IQMJX0qIykfO9eL5Ku-D2kFcbh2QZXE0TOgKLUgO-2cvGbpG-_5zdcsI3hrXtjFnChtso/s1600/127.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJekSt1s_qcJ5EAhpNfyHp4HqkS75YUoHWMEoTDl0GmxmJyz0Y4AOrzMIWR0R89eKYC74UEO_IQMJX0qIykfO9eL5Ku-D2kFcbh2QZXE0TOgKLUgO-2cvGbpG-_5zdcsI3hrXtjFnChtso/s320/127.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
プロジェクトで　ActionBarSherlock　を使えるようにする。&lt;br /&gt;
パッケージエクスプローラからプロジェクトを選択して、&lt;br /&gt;
右クリックからプロパティーを選択する。&lt;br /&gt;
左のAndroid を選択して、ライブラリの追加ボタンをクリックする。&lt;br /&gt;
現れたウインドウから、actionbarsherlock　を選択してOKボタンをクリックする。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-lHPi3t-VKMJrfAFwfRxw_XZj0o5CsKc_dyRToaksoU2IClbbKWwscwdEyeANlnXm86ANU2_Nm90ru0bEBIVrW7wZtNPAfluLbl9Whs6QRjx6obf8rgT6b5eUeZ3IsI8wwBaBS_3LHNkZ/s1600/128.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-lHPi3t-VKMJrfAFwfRxw_XZj0o5CsKc_dyRToaksoU2IClbbKWwscwdEyeANlnXm86ANU2_Nm90ru0bEBIVrW7wZtNPAfluLbl9Whs6QRjx6obf8rgT6b5eUeZ3IsI8wwBaBS_3LHNkZ/s320/128.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXi8R37sH_2QDJJgDqXX3VwYg5-ZhSQKhDnJ6Ra3w9Gpzjhj5nitiZXHkH0O2hrzfFKqxkWj7RspZ8i264tyX7CjqTxj97Pe02-8FqNk2fK5F7uOUg6gvAzWknkITrxVPoB-zW8nnnuhBY/s1600/129.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;279&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXi8R37sH_2QDJJgDqXX3VwYg5-ZhSQKhDnJ6Ra3w9Gpzjhj5nitiZXHkH0O2hrzfFKqxkWj7RspZ8i264tyX7CjqTxj97Pe02-8FqNk2fK5F7uOUg6gvAzWknkITrxVPoB-zW8nnnuhBY/s320/129.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
エラーが発生した。&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] Found 2 versions of android-support-v4.jar in the dependency list,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] but not all the versions are identical (check is based on SHA-1 only at this time).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] All versions of the libraries must be the same at this time.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] Versions found are:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] パス: D:\workspaceTop\workspace\actionbarsherlock\libs\android-support-v4.jar&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;長さ: 271754&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;SHA-1: 53307dc2bd2b69fd5533458ee11885f55807de4b&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] パス: D:\workspaceTop\workspace\TabTest\libs\android-support-v4.jar&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;長さ: 556198&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;SHA-1: 4a6be13368bb64c5a0b0460632d228a1a915f58f&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[2013-09-05 08:36:56 - TabTest] Jar mismatch! Fix your dependencies&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
actionbarsherlock　と　自分で作成したプロジェクトで使っている、android-support-v4.jar　が違うと想像されるるので、&lt;br /&gt;
自分で作ったプロジェクトの中のlibsフォルダに入っている、android-support-v4.jar　を&lt;br /&gt;
actionbarsherlock　の中のlibsフォルダにコピーする。&lt;br /&gt;
&lt;br /&gt;
これで本当に準備完了だと思う。&lt;br /&gt;
&lt;br /&gt;
タブが２つあるページを作る&lt;br /&gt;
１つ目のタブに表示する　xml　レイアウトを作成する。&lt;br /&gt;
パッケージエクスプローラからプロジェクトを選択して、右クリックで、&lt;br /&gt;
新規-&amp;gt;Android XML ファイルを選択する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwRTl6CpjmQGq9LwwB0KloSnI9SDlgMbKMiwG9TaVo6FxXE-Vu6YpkEKJV1hr_l1Lngd1VeuHMZAt4pOnDlsxERdrbZKVF7qfA-izDnTcXvyASPerUtt2THOr_vs_xzjdofh0TbTzO2mKk/s1600/130.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwRTl6CpjmQGq9LwwB0KloSnI9SDlgMbKMiwG9TaVo6FxXE-Vu6YpkEKJV1hr_l1Lngd1VeuHMZAt4pOnDlsxERdrbZKVF7qfA-izDnTcXvyASPerUtt2THOr_vs_xzjdofh0TbTzO2mKk/s320/130.png&quot; width=&quot;297&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
fragment_tab1.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot; &amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/textView1&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;Tab1&quot; /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
同様に、&lt;br /&gt;
２つ目のタブに表示する　xml　レイアウトを作成する。&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot; &amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/textView1&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;Tab2&quot; /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
１つ目のタブの　Fragment　を作成する。&lt;br /&gt;
プロジェクトエクスプローラからプロジェクトを選択して、&lt;br /&gt;
src フォルダの中のcom.example.tabtest を選択して、右クリックから新規からクラスを選択する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw94xml6754WGWNuNOy_etcT_OpRY25k8zoNIh3MP1QaV2YXGsWK5kZ9v7XiLl8oVUZ7Ho3_oG_KntCvtPNtUJfUwkIKCQpRJQRJMu3crAkVgjKuxNdLyKRNhF0EWkRmcI_Fr6IjiPYroh/s1600/131.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw94xml6754WGWNuNOy_etcT_OpRY25k8zoNIh3MP1QaV2YXGsWK5kZ9v7XiLl8oVUZ7Ho3_oG_KntCvtPNtUJfUwkIKCQpRJQRJMu3crAkVgjKuxNdLyKRNhF0EWkRmcI_Fr6IjiPYroh/s320/131.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Tab1Fragment.java&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.tabtest;

import android.os.Bundle;  
import android.support.v4.app.Fragment;  
import android.view.LayoutInflater;  
import android.view.View;  
import android.view.ViewGroup;  
  
public class Tab1Fragment extends Fragment {  
    @Override  
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
               
        return inflater.inflate(R.layout.fragment_tab1, container, false);  
    }  
}  
&lt;/pre&gt;
Tab2Fragment.java&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.tabtest;

import android.os.Bundle;  
import android.support.v4.app.Fragment;  
import android.view.LayoutInflater;  
import android.view.View;  
import android.view.ViewGroup;  
  
public class Tab2Fragment extends Fragment {  
    @Override  
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
                 
        return inflater.inflate(R.layout.fragment_tab2, container, false);  
    }  
}  
&lt;/pre&gt;
&lt;br /&gt;
タブを選択した時の処理をする。&lt;br /&gt;
TabListener.java　を作る。&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.tabtest;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;

public class TabListener&amp;lt;T extends Fragment&amp;gt; implements ActionBar.TabListener {

 private Fragment mFragment;
 private final SherlockFragmentActivity mActivity;
 private final String mTag;
 private final Class&amp;lt;T&amp;gt; mClass;

 private static final String TAG = &quot;TabListener&quot;;

 public TabListener(MainActivity activity, String tag, Class&amp;lt;T&amp;gt; clz) {
  // TODO 自動生成されたコンストラクター・スタブ
  mActivity = activity;
  mTag = tag;
  mClass = clz;

  mFragment = mActivity.getSupportFragmentManager().findFragmentByTag(
    mTag);
 }

 /*
  * 概要：　タブが選択されたときの処理
  */
 @Override
 public void onTabSelected(Tab tab, FragmentTransaction ft) {
  // TODO 自動生成されたメソッド・スタブ

  if (mFragment == null) {
   mFragment = Fragment.instantiate(mActivity, mClass.getName());
   FragmentManager fm = mActivity.getSupportFragmentManager();

   fm.beginTransaction().add(android.R.id.content, mFragment, mTag)
     .commit();
  } else {
   if (mFragment.isDetached()) {
    FragmentManager fm = mActivity.getSupportFragmentManager();
    fm.beginTransaction().attach(mFragment).commit();
   }
  }
 }

 /*
  * タブの選択が解除されたときの処理
  */
 @Override
 public void onTabUnselected(Tab tab, FragmentTransaction ft) {
  // TODO 自動生成されたメソッド・スタブ

  FragmentManager fm = mActivity.getSupportFragmentManager();
  fm.beginTransaction().detach(mFragment).commit();
 }

 @Override
 public void onTabReselected(Tab tab, FragmentTransaction ft) {
  // TODO 自動生成されたメソッド・スタブ

 }

}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
MainActivity.java にタブを設定する&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.tabtest;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;

import android.os.Bundle;

public class MainActivity extends SherlockFragmentActivity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // setContentView(R.layout.activity_main);

  // テーマを設定する
  setTheme(R.style.Theme_Sherlock_Light);

  // アクションバーを設定する。
  ActionBar actionBar = getSupportActionBar();
  actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

  actionBar.addTab(actionBar
    .newTab()
    .setText(&quot;タブ１&quot;)
    .setTabListener(
      new TabListener&amp;lt;Tab1Fragment&amp;gt;(this, &quot;tag1&quot;,
        Tab1Fragment.class)));
  actionBar.addTab(actionBar
    .newTab()
    .setText(&quot;タブ２&quot;)
    .setTabListener(
      new TabListener&amp;lt;Tab2Fragment&amp;gt;(this, &quot;tag2&quot;,
        Tab2Fragment.class)));
 }

 // @Override
 // public boolean onCreateOptionsMenu(Menu menu) {
 // // Inflate the menu; this adds items to the action bar if it is present.
 // getMenuInflater().inflate(R.menu.main, menu);
 // return true;
 // }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
参考ページ：&lt;a href=&quot;http://yan-note.blogspot.jp/2012/11/android-actionbarfragmenttabandroid-2x.html&quot;&gt;Android ActionBarとFragmentを使用してTab画面を表示する(Android 2.x)&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/8468431522615716407/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-2xactionbarsherlock.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8468431522615716407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/8468431522615716407'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/09/android-2xactionbarsherlock.html' title='Android 2.x系　でタブを実現：ActionBarSherlock'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTXra1AUpic6-GuW5rC7pyG3JqsJypiQJLv0C56MF-H0amjxNgaIdxhLzGShtmz0kj-D4sJcebcdMFC8Ig3Lm2kRdkW1_bHx1uQuM_TGxo1Jp7YbJpsKI7AxHM_ERWRpBNr3MJh6b8pExk/s72-c/device-2013-09-05-101223.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-4344559533466431342</id><published>2013-08-27T16:23:00.000+09:00</published><updated>2013-08-27T16:40:14.658+09:00</updated><title type='text'>サービスの使い方。バインド、ブロードキャスト</title><content type='html'>サービスとブロードキャストレシーバの利用方法&lt;br /&gt;
サービスの開始は&lt;br /&gt;
startServiceと&lt;br /&gt;
bindServiceをボタンで指定&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.servicetest;

import android.os.Bundle;
import android.os.IBinder;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.util.Log;
import android.view.View;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
 }
 
 @Override
 protected void onResume() {
  super.onResume();
  
  //　broadcastReceiver　の登録
  IntentFilter intentFilter = new IntentFilter();
  intentFilter.addAction(&quot;MY_ACTION&quot;);
  registerReceiver(broadcastReceiver, intentFilter);
 }
 @Override
    protected void onPause() {
        super.onPause();
        //レシーバーの登録解除
        unregisterReceiver(broadcastReceiver);
    }
 /*
  * 概要：ブロードキャストを受け取った時の処理
  */
 private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
  @Override
  public void onReceive(Context context, Intent intent) {
   Bundle bundle = intent.getExtras();
   String str = bundle.getString(&quot;STRING_SERVICE&quot;);

   Log.i(&quot;TAG&quot;, str);
  }
 };

 // ボタンがクリックされた時の処理
 public void setOnClick(View v) {
  switch (v.getId()) {
  case R.id.buttonStart:
   Log.i(&quot;TAG&quot;, &quot;スタートボタンが押された&quot;);
   startService(new Intent(MainActivity.this, MyService.class));
   break;
  case R.id.buttonStop:// stopServiceでサービスの終了
   Log.i(&quot;TAG&quot;, &quot;ストップボタンが押された&quot;);
   stopService(new Intent(MainActivity.this, MyService.class));
   break;
   
  case R.id.buttonBind://doBindService
   Log.i(&quot;TAG&quot;, &quot;バインド　ボタンが押された&quot;);
            doBindService();
            break;
            
  case R.id.buttonUnbind://doUnbindService
   Log.i(&quot;TAG&quot;, &quot;アンバインド　ボタンが押された&quot;);
            doUnbindService();
            break;
 
        default:
            break;
  }
 }
 
 //以下　サービスのバインド処理
 private boolean mIsBound;
 
 private void doBindService() {
  // TODO 自動生成されたメソッド・スタブ
  //サービスとの接続を確立する。明示的にServiceを指定
     //(特定のサービスを指定する必要がある。他のアプリケーションから知ることができない = ローカルサービス)
     bindService(new Intent(MainActivity.this,MyService.class), mConnection, Context.BIND_AUTO_CREATE);
     mIsBound = true;
 }
 
 private void doUnbindService() {
  // TODO 自動生成されたメソッド・スタブ
  if (mIsBound) {
         // コネクションの解除
         unbindService(mConnection);
         mIsBound = false;
     }
 }
 
 private ServiceConnection mConnection = new ServiceConnection() {

  private MyService mBoundService;

  @Override
  public void onServiceConnected(ComponentName className, IBinder service) {
   // TODO 自動生成されたメソッド・スタブ
      Log.i(&quot;TAG&quot;, &quot;onServiceConnected&quot;);
      
          // サービスにはIBinder経由で#getService()してダイレクトにアクセス可能
          mBoundService = ((MyService.MyServiceLocalBinder)service).getService();
   
          //必要であればmBoundServiceを使ってバインドしたサービスへの制御を行う
  }

  @Override
  public void onServiceDisconnected(ComponentName className) {
   // TODO 自動生成されたメソッド・スタブ
    // サービスとの切断(異常系処理)
         // プロセスのクラッシュなど意図しないサービスの切断が発生した場合に呼ばれる。
         mBoundService = null;
         Log.i(&quot;TAG&quot;, &quot;onServiceDisconnected&quot;);
  }
  
 };
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.servicetest;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {

 private static final String TAG = &quot;TAG&quot;;
 private Timer timer;
 
 @Override
 public void onCreate() {
  Log.i(TAG, &quot;onCreate&quot;);

  timer = new Timer();
  timer.schedule(new TimerTask() {

   private int counter;

   @Override
   public void run() {
    counter++;

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction(&quot;MY_ACTION&quot;);
    broadcastIntent.putExtra(&quot;STRING_SERVICE&quot;, &quot;asd&quot; + counter);
    getBaseContext().sendBroadcast(broadcastIntent);

    Log.v(TAG, &quot;::&quot; + counter);
   }

  }, 1000, 1000);
 }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId) {
  Log.i(TAG, &quot;onStartCommand Received start id &quot; + startId + &quot;: &quot; + intent);
  // 明示的にサービスの起動、停止が決められる場合の返り値
  return START_STICKY;
 }

 @Override
 public void onDestroy() {
  Log.i(TAG, &quot;onDestroy&quot;);
  timer.cancel();//タイマーの停止
 }

 
 //サービスに接続するためのBinder
    public class MyServiceLocalBinder extends Binder {
        //サービスの取得
        MyService getService() {
            return MyService.this;
        }
    }
    
  //Binderの生成
    private final IBinder mBinder = new MyServiceLocalBinder();
    
 @Override
 public IBinder onBind(Intent intent) {
  // TODO 自動生成されたメソッド・スタブ
  Log.i(TAG, &quot;onBind&quot; + &quot;: &quot; + intent);
  return mBinder;
 }
 
 @Override
 public void onRebind(Intent intent) {
  Log.i(TAG, &quot;onRebind&quot; + &quot;: &quot; + intent);
 }
 
 @Override
 public boolean onUnbind(Intent intent) {
  Log.i(TAG, &quot;onUnbind&quot; + &quot;: &quot; + intent);

  // onUnbindをreturn trueでoverrideすると次回バインド時にonRebildが呼ばれる
  return true;
 }

}

&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/4344559533466431342/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/08/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/4344559533466431342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/4344559533466431342'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/08/blog-post.html' title='サービスの使い方。バインド、ブロードキャスト'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-1194672855111819773</id><published>2013-07-24T20:44:00.004+09:00</published><updated>2013-07-24T20:45:19.459+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NDK"/><title type='text'>Android NDK に挑戦</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbY2BRgacC2whBPbKXDqeBFHd18bLe-nkYtPGJuzbrXYUoTtf6JG-y6EjuIgYtDG25JPPR_99cMt26kqktmlSqLGAiOWXVtde4ud-gXzR4lYYXlKEKxxOPeq9aL5en7rZgIT4ozfydisXu/s1600/113.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbY2BRgacC2whBPbKXDqeBFHd18bLe-nkYtPGJuzbrXYUoTtf6JG-y6EjuIgYtDG25JPPR_99cMt26kqktmlSqLGAiOWXVtde4ud-gXzR4lYYXlKEKxxOPeq9aL5en7rZgIT4ozfydisXu/s1600/113.png&quot; height=&quot;91&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
やっと、HelloJni が動いたのでメモ&lt;br /&gt;
&lt;br /&gt;
SDK は　adt-bundle-windows-x86_64-20130717.zip　を解凍して利用&lt;br /&gt;
&lt;br /&gt;
eclipse は　adt-bundle-windows-x86_64-20130717　の中にあるやつを利用。&lt;br /&gt;
&lt;br /&gt;
NDK　は　android-ndk-r8e-windows-x86_64.zip　を解凍して利用&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
eclipseの設定&lt;br /&gt;
NDK Location を設定&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0qxbl_dPBuWfnR78V8S-s3eqkHiLhMdlg4K_ob-ndaSieqK-Ll7TGqfCU7BdVSlS_0-03wGTEak0lUgG2ah8WdfKIqYyvfXbjtBwSMZvwbjqwHp6G0374LMw8QVvgmMzTQ8Qs9Gd5p_TV/s1600/114.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0qxbl_dPBuWfnR78V8S-s3eqkHiLhMdlg4K_ob-ndaSieqK-Ll7TGqfCU7BdVSlS_0-03wGTEak0lUgG2ah8WdfKIqYyvfXbjtBwSMZvwbjqwHp6G0374LMw8QVvgmMzTQ8Qs9Gd5p_TV/s1600/114.png&quot; height=&quot;125&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
サンプルをワークスペースに読み込む。&lt;br /&gt;
ファイルからエクスポートを選択する。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHPp4k0-Zx5NxOnnNJArCYIMEpUXqVb45c-LQsRCkeFp5jUzufXvDIE6lRLOvARw8lelRjqbOrnamv7QBbUfQ8l8gXLLz63Ag5-4MZKxqBTPfX4x-ZUmSDbR7qw3AzvA9HRwcCbK8X1eAt/s1600/115.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHPp4k0-Zx5NxOnnNJArCYIMEpUXqVb45c-LQsRCkeFp5jUzufXvDIE6lRLOvARw8lelRjqbOrnamv7QBbUfQ8l8gXLLz63Ag5-4MZKxqBTPfX4x-ZUmSDbR7qw3AzvA9HRwcCbK8X1eAt/s1600/115.png&quot; height=&quot;320&quot; width=&quot;305&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
D:\soft\android-ndk-r8e\samples\hello-jni を選択して、&lt;br /&gt;
ワークスペースにコピーにチェックを入れる。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEhEeovW8XUaRyXRKTegcTXibORg4sm8nWKtCNzPVP_prIlE3s6haxM3txrqtvVhbpOMfRcQNasltvvcoK9mATUxHnaOSzCEGdC9Lrxcl_Ic1tQqjJlVBnityQmEH2KWlt2gc4hhyn9XLQ/s1600/116.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEhEeovW8XUaRyXRKTegcTXibORg4sm8nWKtCNzPVP_prIlE3s6haxM3txrqtvVhbpOMfRcQNasltvvcoK9mATUxHnaOSzCEGdC9Lrxcl_Ic1tQqjJlVBnityQmEH2KWlt2gc4hhyn9XLQ/s1600/116.png&quot; height=&quot;320&quot; width=&quot;313&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
読み込まれたプロジェクトを右クリックして、&lt;br /&gt;
Android Tool から Add Native Support...　を選択する。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD8IYHT4Td4qh_Qgl-tsQjjMFsm6SysxHVWqu6XhmQwVA-7juDEfPdUkJ0PecAeC2FQtxkZ4PpcEasBS4XU64Ey6X7JXEggVLoPYHHUMm5ngVrVacEkiO7qLXn85jx1Z68Z8S5Wf06zDoz/s1600/117.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD8IYHT4Td4qh_Qgl-tsQjjMFsm6SysxHVWqu6XhmQwVA-7juDEfPdUkJ0PecAeC2FQtxkZ4PpcEasBS4XU64Ey6X7JXEggVLoPYHHUMm5ngVrVacEkiO7qLXn85jx1Z68Z8S5Wf06zDoz/s1600/117.png&quot; height=&quot;320&quot; width=&quot;311&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
そのまま　フィニッシュ&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRIdw02SjTTIl-b2UBTJhvjw7QQSJRIGBGgqsRjMOfmy1BGlQYZBC3e_kQFptPtAtswSUBk1sAcP_IH5dCPAS1T3DQHGn5Z-3ugV_j3SAZDxCySP1kk3q0FkIkxFbeCThnjpTvDW2Z2DaC/s1600/118.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRIdw02SjTTIl-b2UBTJhvjw7QQSJRIGBGgqsRjMOfmy1BGlQYZBC3e_kQFptPtAtswSUBk1sAcP_IH5dCPAS1T3DQHGn5Z-3ugV_j3SAZDxCySP1kk3q0FkIkxFbeCThnjpTvDW2Z2DaC/s1600/118.png&quot; height=&quot;264&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
このまま実行してもエラーが出る。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUak2lpLj-RVlyv2Sd1S8ystrC2o1UG-LM_nyuTnN2SyK_lh1I3tV4vy9_vKMLDFDTBGpSuOPLQTK6d_Rc3mIbdVdtKT3jykJmRj7i9FKtaTKsi0CMYt5JKW1rjI1L-PS_kgkT1LK8gaEO/s1600/119.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUak2lpLj-RVlyv2Sd1S8ystrC2o1UG-LM_nyuTnN2SyK_lh1I3tV4vy9_vKMLDFDTBGpSuOPLQTK6d_Rc3mIbdVdtKT3jykJmRj7i9FKtaTKsi0CMYt5JKW1rjI1L-PS_kgkT1LK8gaEO/s1600/119.png&quot; height=&quot;92&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
sdk のバージョンを調整する。&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
Android SDK Manager で Android 2.3.3 のパッケージをダウンロードする。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHkqIm-2hT-9LKXoY3qG0HvN-c5dJ-XPAUdgFUWbGIdGyIO9hwAL-qch6ESYQOUxQbc8JxLC-WWP0eU1HQekzhEUdqfJv9dBVOjg0Hu2GwORvEIyY_8CzSadXFYfqMfP70lPOBxVgn7Lh/s1600/120.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHkqIm-2hT-9LKXoY3qG0HvN-c5dJ-XPAUdgFUWbGIdGyIO9hwAL-qch6ESYQOUxQbc8JxLC-WWP0eU1HQekzhEUdqfJv9dBVOjg0Hu2GwORvEIyY_8CzSadXFYfqMfP70lPOBxVgn7Lh/s1600/120.png&quot; height=&quot;228&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
eclipse の再起動が必要かも&lt;br /&gt;
&lt;hr /&gt;
AVD を作成する。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdfMeCV0qLH9R544GqsIl3GbnEDhzeYu_uq4iCY5VXSKwszjQq0nJ5u0yqZk3pMbxpMGGACn7ShFMGvKM9CEhVig0rHql2V_xLMtlfuR5UWZHOM31rNc8_4HJ1xVUgjzdelFgdC7kGgxxx/s1600/121.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdfMeCV0qLH9R544GqsIl3GbnEDhzeYu_uq4iCY5VXSKwszjQq0nJ5u0yqZk3pMbxpMGGACn7ShFMGvKM9CEhVig0rHql2V_xLMtlfuR5UWZHOM31rNc8_4HJ1xVUgjzdelFgdC7kGgxxx/s1600/121.png&quot; height=&quot;71&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
ビルドターゲットを変更する。&lt;br /&gt;
パッケージエクスプローラからブロジェクトを選んで右クリックして、&lt;br /&gt;
プロパティーを選択して、&lt;br /&gt;
Android 2.3.3 をを選択する。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCfRGCPxnWptanhPMnBIzMKKPcLDD8m1MyMDl0S0MVqZzBGhShH-axQnwh-q572y6HRLbDGaO95U3hj6LMrOyaH77JKkSC9sSSbCLLJgJNwjfdJEpCksU0hR1vqTBShTrvjj9Wzyo2TN_J/s1600/122.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCfRGCPxnWptanhPMnBIzMKKPcLDD8m1MyMDl0S0MVqZzBGhShH-axQnwh-q572y6HRLbDGaO95U3hj6LMrOyaH77JKkSC9sSSbCLLJgJNwjfdJEpCksU0hR1vqTBShTrvjj9Wzyo2TN_J/s1600/122.png&quot; height=&quot;279&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;hr /&gt;
マニフェストの&amp;nbsp;minSdkVersion を９に変更する&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7UN9wcHmnhmT129ywYzcCgIuKCaxAogaUGLE7jmEhEpD9aXcFUAv9wEuigCZ4c_Z1qPphf9YgQBArmThyAwGulThfmkj4VFkrFmcpNb5I8qYQDmpNuWrWIdLzy8vr3emsYW4-xybxq8-9/s1600/123.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7UN9wcHmnhmT129ywYzcCgIuKCaxAogaUGLE7jmEhEpD9aXcFUAv9wEuigCZ4c_Z1qPphf9YgQBArmThyAwGulThfmkj4VFkrFmcpNb5I8qYQDmpNuWrWIdLzy8vr3emsYW4-xybxq8-9/s1600/123.png&quot; height=&quot;177&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
たぶんこの辺が重要なんだろうか。&lt;br /&gt;
&lt;hr /&gt;
C++ のパースペクティブから、&lt;br /&gt;
プロジェクトのクリーン、&lt;br /&gt;
プロジェクトのビルド、をして、&lt;br /&gt;
実行すれば完了。&lt;br /&gt;
&lt;br /&gt;
感想。&lt;br /&gt;
いろいろなサイトで、環境変数の登録との説明とかがあったが、&lt;br /&gt;
今のところ必要ないようです。&lt;br /&gt;
&lt;br /&gt;
JNI は　、Java　から　C++ のライブラリを使ったり、その逆のための仕組み。&lt;br /&gt;
Android 固有の仕組みではない。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/1194672855111819773/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/android-ndk.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1194672855111819773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1194672855111819773'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/android-ndk.html' title='Android NDK に挑戦'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbY2BRgacC2whBPbKXDqeBFHd18bLe-nkYtPGJuzbrXYUoTtf6JG-y6EjuIgYtDG25JPPR_99cMt26kqktmlSqLGAiOWXVtde4ud-gXzR4lYYXlKEKxxOPeq9aL5en7rZgIT4ozfydisXu/s72-c/113.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-3065914897306248998</id><published>2013-07-18T15:35:00.003+09:00</published><updated>2013-07-18T15:35:45.729+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ListView"/><title type='text'>ListView の最後の行の下線を表示させる</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_mcN9gg3ZUt9cRWxu2NWnLbLuN0UezAZAs2q4BxrI989Yw6lzI6O5lLG2_6KFvayFHDgzAB_Ujhpm2XfHnFXfkCz7SsKmG0Y8qTh6t-mLtOoqDlLP-sshpRqqC5HLGAfgoPULRJMePBVM/s1600/111.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_mcN9gg3ZUt9cRWxu2NWnLbLuN0UezAZAs2q4BxrI989Yw6lzI6O5lLG2_6KFvayFHDgzAB_Ujhpm2XfHnFXfkCz7SsKmG0Y8qTh6t-mLtOoqDlLP-sshpRqqC5HLGAfgoPULRJMePBVM/s320/111.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
layout_height の指定を、wrap_content から、match_parent に変更する。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;  &amp;lt;ListView
        android:id=&quot;@+id/listView&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot; &amp;gt;
    &amp;lt;/ListView&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/3065914897306248998/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/listview_18.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3065914897306248998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/3065914897306248998'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/listview_18.html' title='ListView の最後の行の下線を表示させる'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_mcN9gg3ZUt9cRWxu2NWnLbLuN0UezAZAs2q4BxrI989Yw6lzI6O5lLG2_6KFvayFHDgzAB_Ujhpm2XfHnFXfkCz7SsKmG0Y8qTh6t-mLtOoqDlLP-sshpRqqC5HLGAfgoPULRJMePBVM/s72-c/111.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-1724437999736712127</id><published>2013-07-18T15:21:00.002+09:00</published><updated>2013-07-18T15:49:00.887+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ListView"/><title type='text'>ListViewの中のボタンの処理</title><content type='html'>ListView　の中のボタンを押したら２行目を非表示にする。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilQe2QnFD1NBiczWtTPEjeqS2f0ADXHzVVwEsl-Vksym5Y9nUpSb7BhwPBObsxq7ve383Xt7aBy8WeHc9QRRUJy20McCKbUTloea_VbsxXQVDwTBxfi2WLjxC2c1IWqTZP0GUSS6z5zPvp/s1600/111.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilQe2QnFD1NBiczWtTPEjeqS2f0ADXHzVVwEsl-Vksym5Y9nUpSb7BhwPBObsxq7ve383Xt7aBy8WeHc9QRRUJy20McCKbUTloea_VbsxXQVDwTBxfi2WLjxC2c1IWqTZP0GUSS6z5zPvp/s320/111.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
１行目のボタンを押した場合↓&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinrL_pR9-4RnUUBClzMz-QJSMrkEY3j4CBRJtIh5m4szFHxurggHzstUbDvbxQzA6PWjzp1orQ54bIUMvkxaJ-cJ0hBrDTJ6yNzzwF5r0yz9v2KgxK4iY2_1Ct1D4HSnxlRJRqvvw2kyQH/s1600/112.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinrL_pR9-4RnUUBClzMz-QJSMrkEY3j4CBRJtIh5m4szFHxurggHzstUbDvbxQzA6PWjzp1orQ54bIUMvkxaJ-cJ0hBrDTJ6yNzzwF5r0yz9v2KgxK4iY2_1Ct1D4HSnxlRJRqvvw2kyQH/s320/112.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.listviewtest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.app.Activity;
import android.widget.ListView;

public class MainActivity extends Activity {

 private HashMap&amp;lt;String, String&amp;gt; data;

 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  List&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt; dataList = new ArrayList&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt;();

  Map&amp;lt;String, String&amp;gt; data = new HashMap&amp;lt;String, String&amp;gt;();
  data.put(&quot;title&quot;, &quot;タイトル欄&quot;);
  data.put(&quot;comment&quot;, &quot;COMMENT欄&quot;);
  dataList.add(data);

  data = new HashMap&amp;lt;String, String&amp;gt;();
  data.put(&quot;title&quot;, &quot;タイトル欄２&quot;);
  data.put(&quot;comment&quot;, &quot;COMMENT欄&quot;);
  dataList.add(data);

  MySimpleAdapter adapter = new MySimpleAdapter(
    this, 
    dataList, 
    R.layout.row, 
    new String[] { &quot;title&quot;, &quot;comment&quot; }, 
    new int[] { android.R.id.text1,
    android.R.id.text2 });

  ListView listView = (ListView) findViewById(R.id.listView1);
  listView.setAdapter(adapter);//
 }
}
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;package com.example.listviewtest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class MySimpleAdapter extends SimpleAdapter {

 // private Context context;
 private LayoutInflater inflater;
 private List&amp;lt;? extends Map&amp;lt;String, ?&amp;gt;&amp;gt; listData;

 public class ViewHolder {
  TextView line1;
  TextView line2;
 }

 public MySimpleAdapter(Context context, List&amp;lt;? extends Map&amp;lt;String, ?&amp;gt;&amp;gt; data, int resource, String[] from, int[] to) {
  super(context, data, resource, from, to);
  // TODO 自動生成されたコンストラクター・スタブ
  // this.context = context;
  this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  this.listData = data;
 }

 public View getView(final int position, View convertView, ViewGroup parent) {
  final ViewHolder holder;

  // ビューを受け取る
  View view = convertView;

  if (view == null) {
   view = inflater.inflate(R.layout.row, parent, false);
   // LayoutInflater inflater = (LayoutInflater)
   // context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   // view = inflater.inflate(R.layout.raw, null);

   holder = new ViewHolder();
   holder.line1 = (TextView) view.findViewById(android.R.id.text1);
   holder.line2 = (TextView) view.findViewById(android.R.id.text2);

   view.setTag(holder);
  } else {
   holder = (ViewHolder) view.getTag();
  }

  String text1 = ((HashMap&amp;lt;?, ?&amp;gt;) listData.get(position)).get(&quot;title&quot;).toString();
  String text2 = ((HashMap&amp;lt;?, ?&amp;gt;) listData.get(position)).get(&quot;comment&quot;).toString();
  holder.line1.setText(text1);
  holder.line2.setText(text2);

  Button btn = (Button) view.findViewById(R.id.button1);
  btn.setTag(position);
  
  btn.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View arg0) {
    // TODO 自動生成されたメソッド・スタブ
    Log.v(&quot;buttonクリック&quot;, &quot;ポジション：　&quot; + position);
    if(holder.line2.getVisibility() == android.view.View.GONE){
     holder.line2.setVisibility(View.VISIBLE);
    }else
    holder.line2.setVisibility(View.GONE);
   }
  });
 
  return view;
 }
}
&lt;/pre&gt;
main.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot; &amp;gt;

    &amp;lt;ListView
        android:id=&quot;@+id/listView1&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot; &amp;gt;
    &amp;lt;/ListView&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
row.xml&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&amp;gt;

    &amp;lt;LinearLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot; &amp;gt;

        &amp;lt;TextView
            android:id=&quot;@android:id/text1&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;match_parent&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;TextView&quot;
            android:textSize=&quot;18dp&quot; /&amp;gt;

        &amp;lt;Button
            android:id=&quot;@+id/button1&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;Button&quot; /&amp;gt;

    &amp;lt;/LinearLayout&amp;gt;
 
    &amp;lt;TextView
        android:id=&quot;@android:id/text2&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;TextView&quot; &amp;gt;
    &amp;lt;/TextView&amp;gt;
 
&amp;lt;/LinearLayout&amp;gt;

&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/1724437999736712127/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/listview.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1724437999736712127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1724437999736712127'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/listview.html' title='ListViewの中のボタンの処理'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilQe2QnFD1NBiczWtTPEjeqS2f0ADXHzVVwEsl-Vksym5Y9nUpSb7BhwPBObsxq7ve383Xt7aBy8WeHc9QRRUJy20McCKbUTloea_VbsxXQVDwTBxfi2WLjxC2c1IWqTZP0GUSS6z5zPvp/s72-c/111.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1830398599758101838.post-1647676731830257133</id><published>2013-07-17T09:53:00.000+09:00</published><updated>2013-07-17T13:33:26.130+09:00</updated><title type='text'>GPSを利用する</title><content type='html'>AndroidManifest.xmlにパーミッションを設定する。&lt;br /&gt;
&lt;br /&gt;
GPSによる位置情報利用
&lt;br /&gt;
&amp;lt;uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ネットワークによる位置情報利用&lt;br /&gt;
&amp;lt;uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ロケーションマネージャーのインスタンスを取得&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;GPSの状態を取得する&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;locationManager.addGpsStatusListener(this);
&lt;/pre&gt;
&lt;pre class=&quot;brush: java;&quot;&gt; /*
  * Listener
  * GPS の状態が通知されるメソッド
  */
 @Override
 public void onGpsStatusChanged(int event) {
  // TODO 自動生成されたメソッド・スタブ
  String status = &quot;&quot;;
  if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {
   status = &quot;FIRST FIX：初めて位置情報を確定した：&quot;;
  } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
   status = &quot;SATELLITE STATUS：GPSが位置情報を取得中&quot;;
  } else if (event == GpsStatus.GPS_EVENT_STARTED) {
   status = &quot;STARTED：GPSを使い位置情報の取得を開始した&quot;;
  } else if (event == GpsStatus.GPS_EVENT_STOPPED) {
   status = &quot;STOPPED：GPSの位置情報取得が終了した&quot;;
  }
  Log.d(&quot;onGpsStatusChanged&quot;, status);
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;利用できるプロバイダの一覧表示&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;List&amp;lt;String&amp;gt; providers = locationManager.getAllProviders();
  for (String provider : providers) {
   Log.d(&quot;providers&quot;, provider);
  }
&lt;/pre&gt;
&lt;br /&gt;
実行結果：&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;07-17 12:55:05.809: D/providers(2053): network
07-17 12:55:05.809: D/providers(2053): passive
07-17 12:55:05.809: D/providers(2053): gps
&lt;/pre&gt;
&lt;br /&gt;
gps(GPS, AGPS) &lt;br /&gt;
人工衛星より位置情報を取得する。&lt;br /&gt;
建物の中や、高い建物付近だとGPSが遮られて位置を取得できない。&lt;br /&gt;
バッテリー消費大。高精度。&lt;br /&gt;
&lt;br /&gt;
network (AGPS, CellID, Wifi MACID) &lt;br /&gt;
携帯端末の基地局や接続しているWifiから位置情報を特定する。&lt;br /&gt;
バッテリー消費中。中精度。&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
passive(CellID, Wifi MACID) &lt;br /&gt;
位置情報取得設定が全てオフの場合実行される。&lt;br /&gt;
network との違いは、AGPSを使用しない事。&lt;br /&gt;
バッテリー消費小。低精度&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;条件を指定して最適なプロバイダを取得する。
&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;  Criteria criteria = new Criteria();
  criteria.setAccuracy(Criteria.ACCURACY_LOW);//細かい位置精度
/*  criteria.setBearingRequired(false); // 方位不要
  criteria.setSpeedRequired(false); // 速度不要
  criteria.setAltitudeRequired(false); // 高度不要
*/  
  String provider = locationManager.getBestProvider(criteria, true); 
  Log.d(&quot;getBestProvider&quot;, provider);//gps
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;プロバイダの状態を表示する&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;  List&amp;lt;String&amp;gt; providers = locationManager.getAllProviders();
    for (String provider : providers) {
    boolean status = locationManager.isProviderEnabled(provider);
    Log.d(&quot;providers&quot;, provider + &quot;::&quot; + status);
  }
&lt;/pre&gt;
表示結果：
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;07-17 13:25:37.829: D/providers(2297): network::false
07-17 13:25:37.830: D/providers(2297): passive::true
07-17 13:25:37.831: D/providers(2297): gps::true
&lt;/pre&gt;
&lt;br /&gt;
使えるプロバイダを取得する場合&lt;br /&gt;
List&amp;lt;String&amp;gt; providers = locationManager.getProviders(true);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamato-iphone.blogspot.com/feeds/1647676731830257133/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/gps.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1647676731830257133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1830398599758101838/posts/default/1647676731830257133'/><link rel='alternate' type='text/html' href='http://yamato-iphone.blogspot.com/2013/07/gps.html' title='GPSを利用する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>