<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>@blog.justoneplanet.info</title>
	<atom:link href="http://blog.justoneplanet.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justoneplanet.info</link>
	<description>日々勉強</description>
	<lastBuildDate>Wed, 08 Feb 2012 02:57:17 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHPで不正な閉じタグを見つける</title>
		<link>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 11:10:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=5000</guid>
		<description><![CDATA[ループは1回にできると思うけどまぁとりあえず。 &#60;?php $str = &#60;&#60;&#60;EOD &#60;html&#62; &#60;body&#62; &#60;center&#62; &#60;form acti [...]]]></description>
			<content:encoded><![CDATA[<p>ループは1回にできると思うけどまぁとりあえず。</p>
<pre class="brush: php;">
&lt;?php
$str = &lt;&lt;&lt;EOD
&lt;html&gt;
&lt;body&gt;
&lt;center&gt;
&lt;form action=&quot;confirm.php&quot; method=&quot;get&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;br&gt;
&lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;
&lt;/center&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
EOD;

preg_match_all(&quot;/&lt;.*?&gt;/&quot;, $str, $matches);
//var_dump($matches);
$ary = array();
$stack = array();

foreach ($matches[0] as $key =&gt; $value) {
    array_push($ary, $value);
}

foreach ($ary as $key =&gt; $value) {
    if (preg_match(&quot;/&lt;\/([a-zA-Z]+)/&quot;, $value, $tag)) {
#        echo &quot;$value\n&quot;;
#        var_dump($tag[1]);
        $isFoundClose = false;
        foreach ($ary as $k =&gt; $v) {
            if (preg_match(&quot;/&lt;{$tag[1]}/&quot;, $v)) {
#                echo &quot;match\n&quot;;
                $isFoundClose = true;
                array_splice($ary, $k, $key - $k);
                break;
            }
        }
        if (!$isFoundClose) {
            echo &quot;error:$value\n&quot;;
        }
    }
    else {

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UITextViewの高さを可変にする</title>
		<link>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 17:17:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4983</guid>
		<description><![CDATA[編集可能なUITextViewを使用するときに入力内容にあわせてUITextViewの高さを変えたい時がある。 ■コード 以下のようにUITextViewを定義する。 textview = [[UITextView al [...]]]></description>
			<content:encoded><![CDATA[<p>編集可能なUITextViewを使用するときに入力内容にあわせてUITextViewの高さを変えたい時がある。</p>
<h3>■コード</h3>
<p>以下のようにUITextViewを定義する。</p>
<pre class="brush: cpp;">
textview = [[UITextView alloc] init];
[textview setFrame:CGRectMake(0, 0, 100, 50)];
[textview setEditable:YES];
[textview setDelegate:self];
</pre>
<p>以下のようにcontentSizeを使用する。</p>
<pre class="brush: cpp;">
-(void)textViewDidChange:(UITextView *)textView {
    CGRect f = textview.frame;
    f.size.height = textview.contentSize.height;
    textview.frame = f;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say Goodbye to the Menu Button</title>
		<link>http://blog.justoneplanet.info/2012/01/27/say-goodbye-to-the-menu-button/</link>
		<comments>http://blog.justoneplanet.info/2012/01/27/say-goodbye-to-the-menu-button/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 10:34:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4980</guid>
		<description><![CDATA[Say Goodbye to the Menu Button（原文）の記事を途中まで結構適当に翻訳してます。何か問題がありましたらお知らせください。 Android 3.0 (Honeycomb)以前、全てのAndroi [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html">Say Goodbye to the Menu Button</a>（原文）の記事を途中まで結構適当に翻訳してます。何か問題がありましたらお知らせください。</p>
<p>Android 3.0 (Honeycomb)以前、全てのAndroidデバイスはメニューに専用のメニューボタンを含有していた。開発者として、関連したオプションをユーザに表示するためやアクティビティのビルトインオプションメニューを使うためにメニューボタンを使うことができた。Honeycombは物理的ボタンへの依存をやめ、ユーザーオプションからのアクションを素早く表示させる一般的な解決策としてActionBarクラスを紹介した。最も直感的で一貫性のあるユーザーエクスペリエンスを提供するために、デザインをメニューボタンの使用からアクションバーの使用に移行するべきである。これは新しいコンセプトではない（アクションバーパターンはHoneycomb以前のAndroidにもあった）。しかしICSの登場によっはより、重要なのは一貫性のあるAndroidユーザーエクスペリエンスを進展させるためにアクションバーを使ったデザインに移行し始めることだ。</p>
<p>Honeycombより古いAndroidもサポートする必要があるので、アクションバーの使用は大変なんじゃないかと心配するかもしれない。しかしながら、Honeycomb以前のデバイスでメニューボタンをサポートし続けることができるのでシンプルであり、新しいデバイスでは少しコードを変えるだけでアクションバーを提供できる。</p>
<p>一言であらわすならば、targetSdkVersionを14にして、オプションメニューを使うならば、アクションバーの一部のアクションにshowAsAction=&#8221;ifRoom&#8221;を記述するだけである。</p>
<h3>■Don’t call it a menu</h3>
<p>ハードウェアメニューボタンに依存するのをやめるだけでなく、メニューボタンを使ったアクティビティについて考えるのを完全にやめるべきである。アクションバー野中に重要なユーザーアクション用のボタンを与えるべきである。</p>
<p>以下のスクリーンショットにおいて、検索用のアクションボタンやアクションバーの右側にアクションオーバーフローを見ることができる。</p>
<p>Android 3.0以降で動作するとき、例えAndroid 3.0以前のバージョンをサポートする（ユーザーオプション・アクションを表示するオプションメニューを使う典型的な）アプリケーションでも、メニューボタンはない。システム・ナビゲーションに出るボタンはレガシーアプリケーションのためにオーバーフローアクションとなる。</p>
<p>これは専門用語を超えた細かいことにこだわっているように見えるかもしれないが、アクションオーバーフローという名前は異なった考え方を促進させる。様々なユーザーオプションを包括したメニューの思考の代わりに、アクションとしてスクリーンに表示したいユーザーオプションがどれなのかをもっと考えるべきである。スクリーンにあるべきでないものは画面にオーバーフローして表示できる。ユーザーは、スクリーン上のアクションボタンと平行して表示されるオーバーフローやオーバーフローボタンをタッチすることによってオーバーフローする他のオプションを見せることができる。</p>
<h3>■Action overflow button for legacy apps</h3>
<p>もしもあなたが既にAndroid 2.3以下をサポートするアプリを開発していて、HoneycombやGalaxy Nexusのようなハードウェアメニューボタンがないデバイス上で動作するとき、システムがシステムナビゲーションのそばにオーバーフローアクションを付加することに気づいたかもしれない。</p>
<p>これはメニューボタンを使ったアプリが機能するようにデザインされたレガシーアプリのための互換性である。しかしながら、このボタンは理想的なユーザーエクスペリエンスを提供しない。実際、オプションメニューを全く使っていないアプリでは、オーバーフローアクションボタンは何もせず混乱を生む。だからAndroid 3.0以上で動作し必要ならばActionBarを使うとき、ナビゲーションバーからオーバーフローアクションを除去するためにレガシーアプリをアップデートするべきである。アプリケーションが現在サポートするデバイスとの下位互換性を維持しながら、全て行うことができる。</p>
<p>You can do so all while remaining [[backward compatible with the devices] [your apps currently support]].</p>
<p>もしアプリがメニューボタンなしに動作するならば、manifest要素の&lt;uses-sdk&gt;の中でサポートするように宣言したAPIレベルに基づいて、システムはオーバフローアクションをナビゲーションバーに加えるかどうか判断する。ロジックは以下のとおりである。</p>
<ol>
<li>minSdkVersionもしくはtargetSdkVersionを11以上にした時、システムはレガシーオーバーフローボタンを付加しない</li>
<li>さもなければ、Android 3.0以上で起動時にシステムはレガシーオーバーフローボタンを付加する。</li>
<li>例外は、minSdkVersionが10以下でtargetSdkVersionが11,12,13でありActionBarを使っていないとき、Android 4.0以上で動作時にシステムはレガシーオーバーフローボタンを付加する</li>
</ol>
<p>この例外はちょっと混乱するかもしれないが、Honeycomb以前のハンドセットとHoneycombのタブレットをサポートするアプリをデザインしたならば、ハンドセットデバイスはメニューボタンを含有しただろうという信頼に基づいている。</p>
<p>従って、オーバーフローアクションボタンがシステムナビゲーションのそばに表示されないことを保証するために、targetSdkVersionを14にするべきである。（古いデバイスをサポートし続けるために、minSdkVersionを記述することができる。）</p>
<h3>■Migrating to the action bar</h3>
<p>もしonCreateOptionsMenuを実装しているオプションメニューを使ったアクティビティを使っていて（targetSdkVersionを14にセットすることによって）システム・ナビゲーションバーからレガシーオーバーフローボタンが消えるならば、ユーザーがアクティビティのアクションとオプションにアクセスする代替手段を提供する必要がある。</p>
<p>スペースが得られるときにアクションバーにそれらを表示するためにアクティビティの最も重要なアクションを提供する&lt;item&gt;要素にshowAsAction=&#8221;ifRoom&#8221;を加える。どのアクションがアクションバーで表示されるかの優先順位を決定するための助けを得るには、<a href="http://developer.android.com/design/patterns/actionbar.html">Android Design’s Action Bar guide</a>を見て欲しい。</p>
<p>アクションバーで一貫したユーザーエクスペリメントを更に提供するために、Android UX Teamによってデザインされたアクションアイコンを使うことを提案する。入手できるアイコンは共通のリフレッシュや削除・アタッチ・スター・共有・などのユーザーの共通アクションをサポートし、デザインはライトとダークのHoloテーマをサポートする。<a href="http://developer.android.com/design/static/download/action_bar_icons-v4.0.zip">Here they are!</a></p>
<p>もしこれらのアイコンが必要としているものに適合せず作る必要がある場合、<a href="http://developer.android.com/design/style/iconography.html">Iconography design guide</a>を見るべきである。</p>
<h3>■Removing the action bar</h3>
<p>もしもアクションバーを必要としないならば、アプリ全体もしくはアクティビティごとに取り除くことができる。（ゲームのような）オプションメニューが使われないアプリやデザイン性に適合しないアプリに適している。Theme.Holo.NoActionBarやTheme.DeviceDefault.NoActionBarのようなテーマを使うことでアクションバーを取り除くことができる。</p>
<p>そのようなテーマを使い後方互換性を残すために、<a href="http://android-developers.blogspot.com/2012/01/holo-everywhere.html">Adam Powell’s post</a>で書かれているように、異なったプラットフォームバージョンに異なったテーマを定義するアンドロイドのリソースシステムが使える。必要なのは現在のプラットフォームバージョンに応じて継承した異なったプラットフォームテーマを定義したあなたのテーマだけである。</p>
<p>例えば、こんな感じであなたのアプリケーションにカスタムテーマを宣言できる。</p>
<pre class="brush: xml;">
&lt;application android:theme=&quot;@style/NoActionBar&quot;&gt;
</pre>
<p>もしくは代わりに個々の&lt;activity&gt;要素でテーマを宣言できる。</p>
<p>Honeycomb以前のデバイスのために、スタンダードプラットフォームテーマを継承するres/values/themes.xmlで以下のテーマをインクルードして欲しい。</p>
<pre class="brush: xml;">
&lt;resources&gt;
    &lt;style name=&quot;NoActionBar&quot; parent=&quot;@android:style/Theme&quot;&gt;
        &lt;!-- Inherits the default theme for pre-HC (no action bar) --&gt;
    &lt;/style&gt;
&lt;/resources&gt;
</pre>
<p>Honeycomb以降のために、NoActionBarテーマを継承したres/values-v11/themes.xmlで以下のテーマをインクルードして欲しい。</p>
<pre class="brush: xml;">
&lt;resources&gt;
    &lt;style name=&quot;NoActionBar&quot; parent=&quot;@android:style/Theme.Holo.NoActionBar&quot;&gt;
        &lt;!-- Inherits the Holo theme with no action bar; no other styles needed. --&gt;
    &lt;/style&gt;
&lt;/resources&gt;
</pre>
<p>実行時に、システムはシステムのAPIバージョンに基づいたNoActionBarテーマに適合したバージョンを適用する。</p>
<h3>■Summary</h3>
<ul>
<li>Androidはもはや専用のメニューボタンを要求しないし、いくつかのデバイスはメニューボタンを持たず、メニューボタンを使う手法から移行すべきである</li>
<li>targetSdkVersionを14にセットしてAndroid 4.0でアプリをテストする</li>
<li>アクションバーに表示したいメニューにshowAsAction=&#8221;ifRoom&#8221;を加える</li>
<li>アクションバーを動作させたくないならば、Theme.Holo.NoActionBarやTheme.DeviceDefault.NoActionBarを用いることで消すことができる</li>
</ul>
<p>アクションバーをどうデザインするべきかについては<a href="http://developer.android.com/design/patterns/actionbar.html">Android Design’s Action Bar guide</a>を参照して欲しい。アクションバーの実装についてのより多くの情報は<a href="http://developer.android.com/guide/topics/ui/actionbar.html">Action Bar developer guide</a>で入手できる。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/27/say-goodbye-to-the-menu-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elastic IPを別のホストに関連付ける</title>
		<link>http://blog.justoneplanet.info/2012/01/21/elastic-ip%e3%82%92%e5%88%a5%e3%81%ae%e3%83%9b%e3%82%b9%e3%83%88%e3%81%ab%e9%96%a2%e9%80%a3%e4%bb%98%e3%81%91%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/21/elastic-ip%e3%82%92%e5%88%a5%e3%81%ae%e3%83%9b%e3%82%b9%e3%83%88%e3%81%ab%e9%96%a2%e9%80%a3%e4%bb%98%e3%81%91%e3%82%8b/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 03:53:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4970</guid>
		<description><![CDATA[Elastic IPを別のホストに関連付けた後でmacのターミナルからsshでアクセスしようとすると以下のようなエラーが出る。 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [...]]]></description>
			<content:encoded><![CDATA[<p>Elastic IPを別のホストに関連付けた後でmacのターミナルからsshでアクセスしようとすると以下のようなエラーが出る。</p>
<pre class="brush: plain;">
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
00:88:66:99:77:aa:bb:cc:dd:ee:ff:11:22:33:44:55.
Please contact your system administrator.
Add correct host key in /Users/name/.ssh/known_hosts to get rid of this message.
Offending key in /Users/name/.ssh/known_hosts:7
RSA host key for 123.123.123.123 has changed and you have requested strict checking.
Host key verification failed.
</pre>
<p>以前に同じ証明書で接続したホストとフィンガープリントが変わっていると警告してくれている。以下のようにして対処する。</p>
<pre class="brush: bash;">
ssh-keygen -R 123.123.123.123
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/21/elastic-ip%e3%82%92%e5%88%a5%e3%81%ae%e3%83%9b%e3%82%b9%e3%83%88%e3%81%ab%e9%96%a2%e9%80%a3%e4%bb%98%e3%81%91%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android-support-v4.jarを使ったプロジェクトのテストをする</title>
		<link>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 16:38:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[テスト]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4948</guid>
		<description><![CDATA[テスト対象のプロジェクトにおいて以下の操作をする。 propaties &#62; Java Build Path &#62; Order and Export &#62; android-support-v4.jarにチェッ [...]]]></description>
			<content:encoded><![CDATA[<p>テスト対象のプロジェクトにおいて以下の操作をする。</p>
<p>propaties &gt; Java Build Path &gt; Order and Export &gt; android-support-v4.jarにチェックを入れる。</p>
<h4>.classpath</h4>
<p>以下のようにexported属性が付加されている。</p>
<pre class="brush: xml;">
&lt;classpathentry exported=&quot;true&quot; kind=&quot;lib&quot; path=&quot;libs/android-support-v4.jar&quot;/&gt;
</pre>
<h4>悪い例</h4>
<p>テストプロジェクトにandroid-support-v4.jarをインポートすると以下のようなエラーがでる。</p>
<pre class="brush: plain;">
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:263)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:185)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:373)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3285)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:987)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3728)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
</pre>
<section class="kakomi">
<h4>参考</h4>
<ul>
<li><a href="http://dtmilano.blogspot.com/2009/12/android-testing-external-libraries.html">Android Testing: External libraries</a></li>
</ul>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでレンダリング後のViewのサイズを取得する</title>
		<link>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 08:51:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[View]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4944</guid>
		<description><![CDATA[onClickなどのユーザイベント実行時に取得するならば以下の方法で取得ができる。 mView.setOnClickListener(new View.OnClickListener(){ @Override publi [...]]]></description>
			<content:encoded><![CDATA[<p>onClickなどのユーザイベント実行時に取得するならば以下の方法で取得ができる。</p>
<pre class="brush: java;">
mView.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v) {
        int width = v.getWidth();
        int height = v.getHeight();
    }
});
</pre>
<p>これを利用して以下のようにすると正しく取得できない。</p>
<pre class="brush: java;">
@Override
public void onCreate(Bundle savedInstanceState) {
    // ...
    int width = mView.getWidth();// 0
    int height = mView.getHeight();// 0
}
</pre>
<p>onCreate, onStart, onResumeではレンダリングが終了していないためサイズが0となる。</p>
<h3>■解決策</h3>
<p>以下のようにViewTreeObserverを利用することでレンダリング後のサイズを取得することができる。</p>
<pre class="brush: java;">
@Override
public void onCreate(Bundle savedInstanceState) {
    // ...
    ViewTreeObserver viewTreeObserver = mView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int width = mView.getWidth();
            int height = mView.getHeight();
        }
    });
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSにHaskellを入れる</title>
		<link>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 05:47:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4917</guid>
		<description><![CDATA[めも。 ■ghc wget http://www.haskell.org/ghc/dist/7.2.2/ghc-7.2.2-x86_64-unknown-linux.tar.bz2 tar xvfj ghc-7.2.2- [...]]]></description>
			<content:encoded><![CDATA[<p>めも。</p>
<h3>■ghc</h3>
<pre class="brush: bash;">
wget http://www.haskell.org/ghc/dist/7.2.2/ghc-7.2.2-x86_64-unknown-linux.tar.bz2
tar xvfj ghc-7.2.2-x86_64-unknown-linux.tar.bz2
cd ghc-7.2.2
./configure --prefix=/usr/local/haskell/ghc/7.2.2
make install
export PATH=/usr/local/haskell/ghc/7.2.2/bin:$PATH
</pre>
<h4>コーディング</h4>
<pre class="brush: bash;">
vim hello.hs
</pre>
<pre class="brush: plain;">
main = putStrLn &quot;Hello World&quot;
</pre>
<h4>実行</h4>
<p>以下のコマンドでコンパイルと実行が同時にできる。</p>
<pre class="brush: bash;">
ghc -e main hello.hs
</pre>
<p>もしくは以下のコマンドを実行する。</p>
<pre class="brush: bash;">
ghc --make hello.hs
./hello
</pre>
<section class="kakomi">
<h4>インタプリタ</h4>
<p>以下のコマンドで起動する。</p>
<pre class="brush: bash;">
ghci
</pre>
<p>以下のようにしてインストールできる。</p>
<pre class="brush: bash;">
Prelude&gt; putStrLn &quot;Hello World&quot;
Hello World
</pre>
<p>以下のようにしてインタプリタを終了できる。</p>
<pre class="brush: bash;">
&lt;ctrl&gt;+D
</pre>
</section>
<h4>エラー</h4>
<pre class="brush: bash;">
&lt;command line&gt;: can't load .so/.DLL for: libgmp.so (libgmp.so: cannot open shared object file: No such file or directory)
</pre>
<p>以下のコマンドで解決できる。</p>
<pre class="brush: bash;">
cd /usr/lib64
ln -s libgmp.so.3 libgmp.so
</pre>
<section class="kakomi">
<h4>参考</h4>
<ul>
<li><a href="http://www.haskell.org/ghc/">The Glasgow Haskell Compiler</a></li>
</ul>
</section>
<h3>■hugs</h3>
<p>インタプリタ。ghciもあるので必要がないと思われる。</p>
<pre class="brush: bash;">
wget http://cvs.haskell.org/Hugs/downloads/2006-09/hugs98-Sep2006.tar.gz
tar xvzf hugs98-Sep2006.tar.gz
cd hugs98-Sep2006
./configure
make
make install
</pre>
<h4>開始</h4>
<pre class="brush: bash;">
hugs
</pre>
<h4>終了</h4>
<pre class="brush: bash;">
&lt;ctrl&gt;+D
</pre>
<h4>Hello World</h4>
<pre class="brush: bash;">
Hugs&gt; putStrLn &quot;Hello World&quot;
Hello World
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでIntentServiceを使う</title>
		<link>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7intentservice%e3%82%92%e4%bd%bf%e3%81%86/</link>
		<comments>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7intentservice%e3%82%92%e4%bd%bf%e3%81%86/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 05:30:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[インテント]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4933</guid>
		<description><![CDATA[IntentServiceを使えば手軽にバックグラウンド処理を行うことができる。 ■コード PostIntentService.java public class PostIntentService extends In [...]]]></description>
			<content:encoded><![CDATA[<p>IntentServiceを使えば手軽にバックグラウンド処理を行うことができる。</p>
<h3>■コード</h3>
<h4>PostIntentService.java</h4>
<pre class="brush: java;">
public class PostIntentService extends IntentService implements PostTask.Observer {
    private int counter = 0;
    private int retry = 2;// 通信をリトライする回数
    private Data mData;

    public PostIntentService() {
        super(&quot;PostIntentService&quot;);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        mData = (Data) intent.getSerializableExtra(&quot;data&quot;);
        // send updating status
        Intent i = new Intent();
        i.setAction(PostResponseReceiver.ACTION_RESPONSE);
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.putExtra(&quot;status&quot;, &quot;updating&quot;);
        sendBroadcast(i);
        execute();
        counter++;
    }

    @Override
    public void onSuccessPost(String result) {
        // send success status
        Intent i = new Intent();
        i.setAction(PostResponseReceiver.ACTION_RESPONSE);
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.putExtra(&quot;status&quot;, &quot;success&quot;);
        sendBroadcast(i);
    }

    @Override
    public void onFailedPost(String result) {
        if (counter &lt; retry) {
            execute();
            counter++;
        }
        else {
            // send failed status
            Intent i = new Intent();
            i.setAction(PostResponseReceiver.ACTION_RESPONSE);
            i.addCategory(Intent.CATEGORY_DEFAULT);
            i.putExtra(&quot;status&quot;, &quot;failed&quot;);
            i.putExtra(&quot;data&quot;, mData);// for reproduct
            sendBroadcast(i);
        }
    }
    private void execute() {
        PostTask task = new PostTask(this);
        task.execute();
    }
}
</pre>
<h4>PostBroadcastReceiver.java</h4>
<pre class="brush: java;">
public class PostBroadcastReceiver extends BroadcastReceiver {
    public static final String ACTION_RESPONSE = &quot;com.example.android.intent.action.POST_PROCESSED&quot;;
    private static final int POST_REQUEST = 100;
    private Observer mObserver;

    public PostBroadcastReceiver(Observer observer) {
        mObserver = observer;
    }

    /**
     * Broadcastをreceiveしたときに実行される
     */
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getStringExtra(&quot;status&quot;).equals(&quot;updating&quot;)) {
        }
        else if (intent.getStringExtra(&quot;status&quot;).equals(&quot;success&quot;)) {
            if (mObserver != null) {
                mObserver.onPostFinished();
            }
        }
        else if (intent.getStringExtra(&quot;status&quot;).equals(&quot;failed&quot;)) {
            if (mObserver != null) {
                mObserver.onPostFailed();
            }
        }
    }

    /**
     * activityなどにimplementsするオブザーバ
     */
    public interface Observer {
        public void onPostFinished();
        public void onPostFailed();
    }
}
</pre>
<h4>クライアントコード</h4>
<p>以下のようにすることでActivityからServiceを開始できる。</p>
<pre class="brush: java;">
Intent intent = new Intent(this, PostIntentService.class);
intent.putExtra(&quot;data&quot;, mData);
startService(intent);
</pre>
<p>以下のように結果を受け取るActivityのonCreateにreceiverをbindしておく必要がある。</p>
<pre class="brush: java;">
IntentFilter filter = new IntentFilter(PostBroadcastReceiver.ACTION_RESPONSE);
filter.addCategory(Intent.CATEGORY_DEFAULT);
receiver = new PostResponseReceiver(this);
registerReceiver(receiver, filter);
</pre>
<p>また、以下のようにonDestroyなどで登録したreceiverを解除しなくてはならない。</p>
<pre class="brush: java;">
unregisterReceiver(receiver);
</pre>
<h4>AndroidManifest.xml</h4>
<p>Serviceは以下のようにマニフェストファイルに登録する必要がある。</p>
<pre class="brush: xml;">
&lt;service android:name=&quot;.PostIntentService&quot; /&gt;
</pre>
<section class="kakomi">
<h4>参考</h4>
<ul>
<li><a href="http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/">Android Fundamentals: IntentService Basics</a></li>
</ul>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7intentservice%e3%82%92%e4%bd%bf%e3%81%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでActivityが切り替わるときのアニメーションを変える</title>
		<link>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/</link>
		<comments>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:36:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4914</guid>
		<description><![CDATA[activityが切り替わるときにアニメーションをさせたくなくなった。 ■実装 res/values/style.xml 以下のようにテーマを定義する。 &#60;resource&#62; &#60;style name=&#038; [...]]]></description>
			<content:encoded><![CDATA[<p>activityが切り替わるときにアニメーションをさせたくなくなった。</p>
<h3>■実装</h3>
<h4>res/values/style.xml</h4>
<p>以下のようにテーマを定義する。</p>
<pre class="brush: xml;">
&lt;resource&gt;
    &lt;style name=&quot;NoAnimationTheme&quot; parent=&quot;android:Theme&quot;&gt;
        &lt;item name=&quot;android:windowAnimationStyle&quot;&gt;@style/Animation.Activity&lt;/item&gt;
    &lt;/style&gt;
    &lt;style name=&quot;Animation.Activity&quot; parent=&quot;android:Animation.Activity&quot;&gt;
        &lt;item name=&quot;android:activityOpenEnterAnimation&quot;&gt;@anim/activity_open_enter&lt;/item&gt;
        &lt;item name=&quot;android:activityOpenExitAnimation&quot;&gt;@anim/activity_open_exit&lt;/item&gt;
        &lt;item name=&quot;android:activityCloseEnterAnimation&quot;&gt;@anim/activity_close_enter&lt;/item&gt;
        &lt;item name=&quot;android:activityCloseExitAnimation&quot;&gt;@anim/activity_close_exit&lt;/item&gt;
    &lt;/style&gt;
&lt;/resource&gt;
</pre>
<section class="kakomi">
<h4>anim/activity_open_enter.xml</h4>
<p>startActivityで開くActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;100%&quot;
        android:toXDelta=&quot;0%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_open_exit.xml</h4>
<p>startActivityで閉じるActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;0%&quot;
        android:toXDelta=&quot;-100%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_close_exit.xml</h4>
<p>finishで閉じるActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;0%&quot;
        android:toXDelta=&quot;100%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_close_open.xml</h4>
<p>finishで開くActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;-100%&quot;
        android:toXDelta=&quot;0%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h5>参考</h5>
<p>上述の内容などは以下のような参考サイトに情報がある。</p>
<ul>
<li><a href="http://www.adamrocker.com/blog/289/activity_open_close_animation.html">ActivityのOpenとCloseをアニメーションさせる</a></li>
<li><a href="http://www.atmarkit.co.jp/fsmart/articles/android21/02.html">アニメーションでAndroidに独創的な画面エフェクトを</a></li>
<li><a href="http://stackoverflow.com/questions/7997753/is-it-possible-to-do-this-android-screen-animation-with-a-viewpager">Is it possible to do this Android screen animation with a ViewPager?</a></li>
<li><a href="http://stackoverflow.com/questions/3925355/android-fadeout-animation-for-splash-screen">Android &#8211; Fadeout animation for splash screen</a></li>
</ul>
</section>
<h4>AndroidManifest.xml</h4>
<h5>アプリケーション全体に適用する</h5>
<p>以下のようにapplicationタグに記述することでアプリケーション全体に変更したアニメーションを適用できる。</p>
<pre class="brush: xml;">
&lt;application
    android:icon=&quot;@drawable/icon&quot;
    android:label=&quot;@string/app_name&quot;
    android:theme=&quot;@style/NoAnimationTheme&quot;&gt;
</pre>
<h5>アクティビティに適用する</h5>
<p>以下のようにactivityタグに記述することで単一のアクティビティにのみ変更したアニメーションを適用できる。</p>
<pre class="brush: xml;">
&lt;activity
    android:label=&quot;@string/app_name&quot;
    android:name=&quot;.MainActivity&quot;&gt;
&lt;/activity&gt;
</pre>
<h3>■応用</h3>
<p>上述の方法だと特定の条件下でのみアニメーションを変えるといったことができない。条件によってanimationを変えたい場合は、以下のようにすることで対応できる。</p>
<pre class="brush: java;">
public class MainActivity extends Activity {
    /**
     * 起動時に実行される
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.NoAnimationTheme);// super.onCreateの前に実行する必要がある
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでギャラリーと連携する</title>
		<link>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 11:38:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[インテント]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4912</guid>
		<description><![CDATA[■実装 ギャラリーの起動 以下のようにすることで（画像データに選択肢を絞って）ギャラリーアプリを起動することができる。 Intent intent = new Intent(); intent.setType(&#038;quot [...]]]></description>
			<content:encoded><![CDATA[<h3>■実装</h3>
<h4>ギャラリーの起動</h4>
<p>以下のようにすることで（画像データに選択肢を絞って）ギャラリーアプリを起動することができる。</p>
<pre class="brush: java;">
Intent intent = new Intent();
intent.setType(&quot;image/*&quot;);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, REQUESTCODE);
</pre>
<h4>ギャラリーからデータを受け取る</h4>
<pre class="brush: java;">
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUESTCODE &amp;&amp; resultCode == RESULT_OK) {
        //data.getData();//ギャラリーで選択したファイルのuriが格納されている
    }
}
</pre>
<section class="kakomi">
<h4>uriからpathの文字列を取得</h4>
<p>以下のようにすることでuriからpathの文字列を取得することができる。</p>
<pre class="brush: java;">
private final String getPathFromUri(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
</pre>
<h5>参考</h5>
<ul>
<li><a href="http://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore">Get filename and path from uri from mediastore</a></li>
</ul>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidで顔検出する</title>
		<link>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 14:19:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4887</guid>
		<description><![CDATA[int maxFaces = 10;// 検出する顔の最大数 FaceDetector detector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: java;">
int maxFaces = 10;// 検出する顔の最大数
FaceDetector detector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), maxFaces);
FaceDetector.Face[] faces = new FaceDetector.Face[maxFaces];
ArrayList&lt;Bitmap&gt; recognized = new ArrayList&lt;Bitmap&gt;();

// bitmapの中から顔を検出してfacesに格納する
int num = detector.findFaces(bitmap, faces);

// facesに格納されたデータから座標情報を取り出してbitmapを切り出す
for (int i = 0; i &lt; num; i++) {
    FaceDetector.Face face = faces[i];
    PointF point = new PointF(0.0f, 0.0f);
    face.getMidPoint(point);

    int x = (int) (point.x - 1.5f * face.eyesDistance());
    int y = (int) (point.y - 2 * face.eyesDistance());
    int width  = (int) (face.eyesDistance() * 3);
    int height = (int) (face.eyesDistance() * 4);
    x = (x &lt; 0)? 0 : x;
    y = (y &lt; 0)? 0 : y;
    width = (width &gt; bitmap.getWidth())? bitmap.getWidth() : width;
    height = (height &gt; bitmap.getHeight())? bitmap.getHeight() : height;
    recognized.add(Bitmap.createBitmap(bitmap, x, y, width, height));
}
return recognized;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでprivateメソッドのテストをする</title>
		<link>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 16:53:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4882</guid>
		<description><![CDATA[そういえば書いてなかったのでメモ。 /** * Hogeクラスのprivateメソッドadd(int a, int b)をテストする * @throws SecurityException * @throws Illeg [...]]]></description>
			<content:encoded><![CDATA[<p>そういえば書いてなかったのでメモ。</p>
<pre class="brush: java;">
    /**
     * Hogeクラスのprivateメソッドadd(int a, int b)をテストする
     * @throws SecurityException
     * @throws IllegalArgumentException
     * @throws NoSuchMethodException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public void testAdd() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        Hoge hoge = new Hoge();
        Class&lt;Hoge&gt; clz = Hoge.class;
        Method method = clz.getDeclaredMethod(&quot;add&quot;, Integer.class, Integer.class);
        method.setAccessible(true);
        int result = (int) method.invoke(hoge, 5, 3);
        asserTrue(result == 8);
    }
</pre>
<p>staticメソッドの場合は以下のようになる。</p>
<pre class="brush: java;">
    /**
     * Hogeクラスのprivate staticメソッドadd(int a, int b)をテストする
     * @throws SecurityException
     * @throws IllegalArgumentException
     * @throws NoSuchMethodException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public void testAdd() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        Class&lt;Hoge&gt; clz = Hoge.class;
        Method method = clz.getDeclaredMethod(&quot;add&quot;, Integer.class, Integer.class);
        method.setAccessible(true);
        int result = (int) method.invoke(clz, 5, 3);
        asserTrue(result == 8);
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

