<?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-7548542647492673021</id><updated>2026-10-17T16:18:32.573+09:00</updated><category term="Android App Developer"/><category term="Android building"/><category term="android frameworks"/><category term="Android JUnit Test"/><category term="Swift"/><category term="Android AOSP"/><category term="BeagleBoneBlack"/><category term="Espresso"/><category term="Binding"/><category term="KitKat"/><title type='text'>baroqueworksdev blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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>75</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-8641161825676531638</id><published>2021-07-05T00:11:00.000+09:00</published><updated>2021-07-05T00:11:05.154+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Swift"/><title type='text'>画面幅より短い場合はCenterさせるUIScrollViewを作成する</title><content type='html'>次のようなViewを条件を満たすViewを作りたくなったので実装してみました。&lt;/b&gt;

&lt;div&gt;
  &lt;ul style=&quot;text-align: left;&quot;&gt;
    &lt;li&gt;画面幅より短い場合は、Center表示させる&lt;/li&gt;
    &lt;li&gt;画面幅より長い場合は、左寄せで表示し横スクロール可能である&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;br /&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/AVvXsEh8LTPrp8lLz1aaC5OupjintGeAQ2iTDaReaDxiT9CYlG0WPMCnlSExJ3OukvKounQ8my_HLyEj-JJdR29pdY3K9aLAyQtg6v1rdnLT3Dllf9jpkgksZiNYQtstKXkzmFlQlqoO7h84IdoK/s872/UIScrollView_sample1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;578&quot; data-original-width=&quot;872&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8LTPrp8lLz1aaC5OupjintGeAQ2iTDaReaDxiT9CYlG0WPMCnlSExJ3OukvKounQ8my_HLyEj-JJdR29pdY3K9aLAyQtg6v1rdnLT3Dllf9jpkgksZiNYQtstKXkzmFlQlqoO7h84IdoK/s320/UIScrollView_sample1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;


&lt;h2&gt;Viewの構成&lt;/h2&gt;

Viewの構成は、UIScrollViewの中にコンテンツ用のUIViewを入れるのみです。
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    private let scrollView = UIScrollView()
    private let contentView = UIView()


    private func setupViews() {
        scrollView.addSubview(contentView)
        addSubview(scrollView)
    }
&lt;/pre&gt;
&lt;br /&gt;
実際に表示させたいViewは、次のようにfunc setup(_)メソッドを使って挿入させることを想定しています。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    func setup(_ view: UIView) {
        contentView.addSubview(view)
        view.snp.makeConstraints {
            $0.edges.equalTo(contentView)
        }
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;


&lt;h2&gt;制約をセットする&lt;/h2&gt;
scrollViewの制約は、通常通り親Viewに対して同じ大きさになるよう制約をセットします。&lt;br /&gt;
contentViewの制約は工夫が必要で、親Viewに対して横Centerの指定とleftに対してgreaterThanOrEqualToを指定します。&lt;br /&gt;
この2つの制約によりCenter表示が可能になります。&lt;br /&gt;

&lt;pre class=&quot;brush: java;&quot;&gt;
    private func setupConstraint() {
        scrollView.snp.makeConstraints {
            $0.edges.equalToSuperview()
        }
        contentView.snp.makeConstraints {
            $0.height.equalTo(scrollView.frameLayoutGuide)
            // 横幅より小さい場合は、Center
            // 横幅より大きい場合は、通常の左寄せ + スクロール
            $0.top.right.bottom.equalTo(scrollView.contentLayoutGuide)
            $0.left.equalTo(scrollView.contentLayoutGuide).priority(.low)
            $0.left.greaterThanOrEqualTo(scrollView.contentLayoutGuide)
            $0.centerX.greaterThanOrEqualToSuperview()
        }
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;

ScrollのContent領域が定まらないというLayoutのwarningが発生したため、次の制約を追加します。
&lt;pre class=&quot;brush: java;&quot;&gt;
$0.left.equalTo(scrollView.contentLayoutGuide).priority(.low)
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;完成形のコード&lt;/h2&gt;
上記の全てを組み合わせると、次のようなコードになります。

&lt;pre class=&quot;brush: java;&quot;&gt;
final class HorizontalScrollView: UIView {
    private let scrollView = UIScrollView()
    private let contentView = UIView()

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupViews()
        setupConstraint()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupViews()
        setupConstraint()
    }

    private func setupViews() {
        scrollView.addSubview(contentView)
        addSubview(scrollView)
    }

    private func setupConstraint() {
        scrollView.snp.makeConstraints {
            $0.edges.equalToSuperview()
        }
        contentView.snp.makeConstraints {
            $0.height.equalTo(scrollView.frameLayoutGuide)
            // aligin center when content width &lt; frame width
            // aligin left when content width &gt; frame width
            $0.top.right.bottom.equalTo(scrollView.contentLayoutGuide)
            $0.left.equalTo(scrollView.contentLayoutGuide).priority(.low)
            $0.left.greaterThanOrEqualTo(scrollView.contentLayoutGuide)
            $0.centerX.greaterThanOrEqualToSuperview()
        }
    }

    func setup(_ view: UIView) {
        contentView.addSubview(view)
        view.snp.makeConstraints {
            $0.edges.equalTo(contentView)
        }
    }
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/8641161825676531638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2021/07/centeruiscrollview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8641161825676531638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8641161825676531638'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2021/07/centeruiscrollview.html' title='画面幅より短い場合はCenterさせるUIScrollViewを作成する'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEh8LTPrp8lLz1aaC5OupjintGeAQ2iTDaReaDxiT9CYlG0WPMCnlSExJ3OukvKounQ8my_HLyEj-JJdR29pdY3K9aLAyQtg6v1rdnLT3Dllf9jpkgksZiNYQtstKXkzmFlQlqoO7h84IdoK/s72-c/UIScrollView_sample1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-7956936766570330802</id><published>2019-09-07T07:58:00.001+09:00</published><updated>2019-09-07T07:58:57.512+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Swift"/><title type='text'>[Swift] Do not work backgound color of UITableViewHeaderFooterView</title><content type='html'>&lt;h2&gt;UITableViewHeaderFooterView can not set backgound color&lt;/h2&gt;
&lt;/br&gt;
We can not set the backgound color on UITableViewHeaderFooterView.&lt;/br&gt;
If set, we see the following log.&lt;/br&gt;
&lt;/br&gt;
&quot;Setting the background color on UITableViewHeaderFooterView has been deprecated. Please use contentView.backgroundColor instead.&quot;&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
if change backgroundColor, use the &quot;contentView&quot; that is included in UITableViewHeaderFooterView.
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    sectionHeader?.contentView.backgroundColor = backgroundColor
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/7956936766570330802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2019/09/swift-do-not-work-backgound-color-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7956936766570330802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7956936766570330802'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2019/09/swift-do-not-work-backgound-color-of.html' title='[Swift] Do not work backgound color of UITableViewHeaderFooterView'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-1294378427229510807</id><published>2019-08-17T14:00:00.000+09:00</published><updated>2019-08-17T14:00:05.397+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Swift"/><title type='text'>How to use UIScreenEdgePanGestureRecognizer, via Swift Code</title><content type='html'>&lt;h2&gt;implement in UIViewController&lt;/h2&gt;
&lt;/br&gt;
I had implemented the screen edge swipe with using UIScreenEdgePanGestureRecognizer,  without Storyboard.&lt;/br&gt;
&lt;/br&gt;
We need to add edgePan to ViewController.view. if you want to handle the acton, you have to use #selector.
&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
class ViewController: UIViewController {

    private let closer = SwipeEdgeCloser()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        let edgePan = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(handleScreenEdgeSwiped))
        edgePan.edges = .left
        view.addGestureRecognizer(edgePan)
    }

    @objc func handleScreenEdgeSwiped(_ recognizer: UIScreenEdgePanGestureRecognizer) {
        if recognizer.state == .recognized {
            print(&quot;Screen edge swiped!&quot;)
        }
    }
}
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h2&gt;new class implemented Edge Swipe Gesture&lt;/h2&gt;
&lt;/br&gt;
If you do not like &quot;fat UIViewController&quot;, you should new class implemented Edge Swipe Gesture.&lt;br&gt;
&lt;/br&gt;
&lt;/br&gt;

&lt;pre class=&quot;brush: java;&quot;&gt;
class ViewController: UIViewController {

    private let closer = SwipeLeftEdgePanGesture()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addGestureRecognizer(closer.panGesture)
    }
}

final class SwipeLeftEdgePanGesture {
    let panGesture: UIScreenEdgePanGestureRecognizer
    
    init() {
        panGesture = UIScreenEdgePanGestureRecognizer()
        panGesture.edges = .left
        panGesture.addTarget(self, action: #selector(SwipeLeftEdgePanGesture.screenEdgeSwiped))
    }
    
    @objc private func screenEdgeSwiped(_ recognizer: UIScreenEdgePanGestureRecognizer) {
        if recognizer.state == .recognized {
            print(&quot;SwipeLeftEdgePanGesture: Screen edge swiped!&quot;)
        }
    }
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/1294378427229510807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2019/08/how-to-use-uiscreenedgepangesturerecogn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1294378427229510807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1294378427229510807'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2019/08/how-to-use-uiscreenedgepangesturerecogn.html' title='How to use UIScreenEdgePanGestureRecognizer, via Swift Code'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-3133603332016388812</id><published>2016-09-05T23:00:00.000+09:00</published><updated>2016-09-05T23:00:34.498+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><category scheme="http://www.blogger.com/atom/ns#" term="Binding"/><title type='text'>Android Binding AppCompatEditText: Add TextWatcher </title><content type='html'>We should implement TextWatcher interface, due to listen to change text.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
public TextWatcher getEditTextWatcher() {
    return new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int start, int count,
                int after) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
            // FIXME: when change text
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    };
}
&lt;/pre&gt;
&lt;br /&gt;
set to app:addTextChangedListener on Layout file.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
&amp;lt;data&amp;gt;
    &amp;lt;variable name=&amp;quot;fragment&amp;quot;
              type=&amp;quot;jp.baroqueworksdev.sample.SampleFragment&amp;quot;/&amp;gt;
&amp;lt;/data&amp;gt;
&amp;lt;android.support.v7.AppCompatEditText
        app:addTextChangedListener=&amp;quot;@{fragment.getEditTextWatcher}&amp;quot;/&amp;gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/3133603332016388812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/09/android-binding-appcompatedittext-add.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3133603332016388812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3133603332016388812'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/09/android-binding-appcompatedittext-add.html' title='Android Binding AppCompatEditText: Add TextWatcher '/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-2570029572471061843</id><published>2016-03-19T12:37:00.000+09:00</published><updated>2016-03-19T12:37:44.248+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Swift"/><title type='text'>[Swift]how to use custom section header of TableView</title><content type='html'>We can use custom section header on UITableView.&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/AVvXsEiHSDRk8iUmW2Oiq3U2FIPnICAWyWhCYl1NBUWVw_0QaWtCbYIk2b51WyXuP5zVsP6tD3_wzxfAkETulEDJ6Vk4gMrN6D8_pUspuN0SDPLXawGU7FDrqK2qC35QIALPdqSBTRRhacrYjkc/s1600/Simulator+Screen+Shot+2016.03.19+10.05.30.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/AVvXsEiHSDRk8iUmW2Oiq3U2FIPnICAWyWhCYl1NBUWVw_0QaWtCbYIk2b51WyXuP5zVsP6tD3_wzxfAkETulEDJ6Vk4gMrN6D8_pUspuN0SDPLXawGU7FDrqK2qC35QIALPdqSBTRRhacrYjkc/s400/Simulator+Screen+Shot+2016.03.19+10.05.30.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Sub class : UITableViewHeaderFooterView&lt;/h4&gt;
UITableViewHeaderFooterViewを継承したクラスを作成します。
We need to implement the sub class of UITableViewHeaderFooterView.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
import UIKit

class CustomTableViewHeaderFooterView: UITableViewHeaderFooterView {

    @IBOutlet weak var headerView: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Nib file&lt;/h4&gt;
We need to implement the view for Header.&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/AVvXsEjg30bDvW-BAj5vGaLuKnLRHY26aBUWVM3tXeq2WL4nHdntcSbnfXNcSUtHuREA23MA8-5jYQ3HLkz8iGDI0p-ddR2G2FGkuoNbIMf1PM-ykINZczfoG40pIXWaJ9xB86ai-MfyheQbOuk/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2016-03-19+12.19.25.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/AVvXsEjg30bDvW-BAj5vGaLuKnLRHY26aBUWVM3tXeq2WL4nHdntcSbnfXNcSUtHuREA23MA8-5jYQ3HLkz8iGDI0p-ddR2G2FGkuoNbIMf1PM-ykINZczfoG40pIXWaJ9xB86ai-MfyheQbOuk/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2016-03-19+12.19.25.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Set to TableView&lt;/h4&gt;
We need to use tableView.registerNib like a Cell. This is used return value in tableView:viewForHeaderInSection method.&lt;br /&gt;
If View width is no good, you need to set frame.size.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
class ViewController: UITableViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let nib:UINib = UINib(nibName: &quot;CustomTableViewHeaderFooterView&quot;, bundle: nil)
        tableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: &quot;CustomTableViewHeaderFooterView&quot;)
    }
    
    override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
        return 1
    }
    
    // header height
    override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat {
        return 44
    }
    
    
    // header view
    override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
        let header :CustomTableViewHeaderFooterView = self.tableView.dequeueReusableHeaderFooterViewWithIdentifier(&quot;CustomTableViewHeaderFooterView&quot;) as! CustomTableViewHeaderFooterView
        header.headerView.frame.size = CGRectMake(0, 0, tableView.frame.size.width, 44).size
        
        return header
    }
    
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/2570029572471061843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/03/swifthow-to-use-custom-section-header.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2570029572471061843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2570029572471061843'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/03/swifthow-to-use-custom-section-header.html' title='[Swift]how to use custom section header of TableView'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEiHSDRk8iUmW2Oiq3U2FIPnICAWyWhCYl1NBUWVw_0QaWtCbYIk2b51WyXuP5zVsP6tD3_wzxfAkETulEDJ6Vk4gMrN6D8_pUspuN0SDPLXawGU7FDrqK2qC35QIALPdqSBTRRhacrYjkc/s72-c/Simulator+Screen+Shot+2016.03.19+10.05.30.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-3212951832779851243</id><published>2016-03-19T08:24:00.000+09:00</published><updated>2016-03-19T08:24:18.860+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>BottomSheet vis Android Design Support Library 23.2.0</title><content type='html'>
Android Design Support Library had added BottomSheet from ver.23.2.&lt;br /&gt;
We can implement BottomSheet design like a GoogleMap.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AOSP: &lt;a href=&quot;https://android.googlesource.com/platform/frameworks/support/+/master/design/src/android/support/design/widget/BottomSheetBehavior.java&quot;&gt;BottomSheetBehavior.java&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Layout Sample&lt;/h4&gt;
We add the param app:layout_behavior=&quot;@string/bottom_sheet_behavior&quot; in child view of CoordinatorLayout.&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
&amp;lt;android.support.design.widget.CoordinatorLayout
        xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;
        xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;
        xmlns:app=&amp;quot;http://schemas.android.com/apk/res-auto&amp;quot;
        android:layout_width=&amp;quot;match_parent&amp;quot;
        android:layout_height=&amp;quot;match_parent&amp;quot;
        tools:context=&amp;quot;.MainActivity&amp;quot;&amp;gt;

    &amp;lt;LinearLayout
            android:layout_width=&amp;quot;match_parent&amp;quot;
            android:layout_height=&amp;quot;match_parent&amp;quot;
            android:orientation=&amp;quot;vertical&amp;quot;
            app:layout_behavior=&amp;quot;@string/bottom_sheet_behavior&amp;quot;
            app:behavior_peekHeight=&amp;quot;240dp&amp;quot;
            app:behavior_hideable=&amp;quot;false&amp;quot;
            android:background=&amp;quot;@android:color/white&amp;quot;&amp;gt;
        &amp;lt;TextView
                android:layout_width=&amp;quot;match_parent&amp;quot;
                android:layout_height=&amp;quot;match_parent&amp;quot;
                android:text=&amp;quot;BottomSheet Sample&amp;quot;/&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/android.support.design.widget.CoordinatorLayout&amp;gt;

&lt;/pre&gt;
We cab add following params.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;app:behavior_peekHeight&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;BottomSheet minimum size&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;app:behavior_hideable&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;BottomSheet is hidden when scroll to bottom.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&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/AVvXsEiRj9vePrDUaSlWUqTD3PWm86vHXIW548rj-Ayt0diVJLz1BWrg-xvzFdamcsVXujrm21T77etml8dSeb-ST8lDXXOn2Rq4T9sLxDFFeMHPOKPo7Z7GD_-USjIeIVMx8NWfMhRrdvE5b9w/s1600/device-2016-03-05-052719.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/AVvXsEiRj9vePrDUaSlWUqTD3PWm86vHXIW548rj-Ayt0diVJLz1BWrg-xvzFdamcsVXujrm21T77etml8dSeb-ST8lDXXOn2Rq4T9sLxDFFeMHPOKPo7Z7GD_-USjIeIVMx8NWfMhRrdvE5b9w/s320/device-2016-03-05-052719.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/3212951832779851243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/03/bottomsheet-vis-android-design-support.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3212951832779851243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3212951832779851243'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2016/03/bottomsheet-vis-android-design-support.html' title='BottomSheet vis Android Design Support Library 23.2.0'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEiRj9vePrDUaSlWUqTD3PWm86vHXIW548rj-Ayt0diVJLz1BWrg-xvzFdamcsVXujrm21T77etml8dSeb-ST8lDXXOn2Rq4T9sLxDFFeMHPOKPo7Z7GD_-USjIeIVMx8NWfMhRrdvE5b9w/s72-c/device-2016-03-05-052719.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-6548873381681144286</id><published>2015-06-21T09:50:00.000+09:00</published><updated>2015-06-21T09:50:38.711+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>CoordinatorLayout has problem which registered to Issue Tracker.</title><content type='html'>CoordinatorLayout has problem which registered to Issue Tracker.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt; Do not show display when Screen rotate&lt;/h4&gt;
If your Activity has configChanges that write on AndroidManifest.xml, CoordinatorLayout do not show display when screen rotate.&lt;br /&gt;
        &lt;activity android:name=&quot;.MainActivity&quot;
                android:configChanges=&quot;orientation|screenSize&quot;&gt;

You can reproduct, Landscape to Portrait.&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/AVvXsEijQ25mzqC6Bz3Z9MkfoJ1mFqAtSQPiidTX_DoVrNfcejnipwn-a-eC4301VJ9kmcpJdYXefNwVt5Xos6nOBROjwFx_iQwBA4Sih1vFPrKxjz09Rc026Mn15ENVxHG-3kBU8lBDFnHDX4g/s1600/device-2015-06-12-225656.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/AVvXsEijQ25mzqC6Bz3Z9MkfoJ1mFqAtSQPiidTX_DoVrNfcejnipwn-a-eC4301VJ9kmcpJdYXefNwVt5Xos6nOBROjwFx_iQwBA4Sih1vFPrKxjz09Rc026Mn15ENVxHG-3kBU8lBDFnHDX4g/s400/device-2015-06-12-225656.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This had been registered to AOSP Issue Tracker.&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=176373&quot;&gt;CoordinatorLayout in design support library does not update child size on rotation&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=176187&quot;&gt;layout_behavior view height doesn&#39;t restore when keyboard goes down / ActionBar ActionView partially visible&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;AppBarLayout do not Animation&lt;/h4&gt;
AppBarLayout do not Animation, release touch event.&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/AVvXsEi2mMd2aqwxrdQxDjptT5_g4ot3W0LZqILsRG5EA2h0_f6igm_Cbbc0fDJztzt1FDNosm4le5l6qcPlJzh4Rk-iLA6jeocwXl0XkRQ47_l5mxedR_-hH0zfh1vIzxu-_B0KvyEwQ-m-fD4/s1600/device-2015-06-13-150333.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/AVvXsEi2mMd2aqwxrdQxDjptT5_g4ot3W0LZqILsRG5EA2h0_f6igm_Cbbc0fDJztzt1FDNosm4le5l6qcPlJzh4Rk-iLA6jeocwXl0XkRQ47_l5mxedR_-hH0zfh1vIzxu-_B0KvyEwQ-m-fD4/s400/device-2015-06-13-150333.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
I think we can implement show / dismiss animation with touch event listener and Behavior#onNestedFling.&lt;br /&gt;
Please advise us best practice.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=175506&quot;&gt;Toolbar should settle when only partially scrolled&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/6548873381681144286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/06/coordinatorlayout-has-problem-which.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6548873381681144286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6548873381681144286'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/06/coordinatorlayout-has-problem-which.html' title='CoordinatorLayout has problem which registered to Issue Tracker.'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEijQ25mzqC6Bz3Z9MkfoJ1mFqAtSQPiidTX_DoVrNfcejnipwn-a-eC4301VJ9kmcpJdYXefNwVt5Xos6nOBROjwFx_iQwBA4Sih1vFPrKxjz09Rc026Mn15ENVxHG-3kBU8lBDFnHDX4g/s72-c/device-2015-06-12-225656.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-7806554768468889014</id><published>2015-06-08T14:34:00.001+09:00</published><updated>2015-06-08T14:34:40.327+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>Hot to use TextInputLayout , Android Support library v22.2</title><content type='html'>I can implement Text field of Material Design too easy.&lt;br /&gt;
http://www.google.com/design/spec/components/text-fields.html#text-fields-single-line-text-field&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
    &amp;lt;android.support.design.widget.TextInputLayout
            android:id=&amp;quot;@+id/textInputLayout&amp;quot;
            android:layout_width=&amp;quot;wrap_content&amp;quot;
            android:layout_height=&amp;quot;wrap_content&amp;quot;
            app:hintTextAppearance=&amp;quot;@style/TextInputLayoutHintAppearance&amp;quot;&amp;gt;
        &amp;lt;EditText
                android:id=&amp;quot;@+id/editText&amp;quot;
                android:layout_width=&amp;quot;wrap_content&amp;quot;
                android:layout_height=&amp;quot;wrap_content&amp;quot;
                android:inputType=&amp;quot;textEmailAddress&amp;quot;
                android:hint=&amp;quot;HintText&amp;quot;
                android:ems=&amp;quot;10&amp;quot;/&amp;gt;
    &amp;lt;/android.support.design.widget.TextInputLayout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dyFAraJlqNNMkMUbzl9yK33mzZx6BNPR48bdBBarOH5NrZOGpJBJnRTY7yyyzO4iLpnBvF0bd9fJRx5iwWxqA&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The each parts color is material color.&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/AVvXsEgZ82En12xdqylWrNbCuB-kV826JX-tfyErHhUC6LqcA05RhfgmSxxZ0Hg3FVjhHXE1VQptL7uigsu4Yn3YLAseN_GLhudnQ2ADZ7jx_zxQrNAyUbjko4e9upiTWdhLKSMaJ1f9ynxZMAc/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2015-06-08+14.19.47.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/AVvXsEgZ82En12xdqylWrNbCuB-kV826JX-tfyErHhUC6LqcA05RhfgmSxxZ0Hg3FVjhHXE1VQptL7uigsu4Yn3YLAseN_GLhudnQ2ADZ7jx_zxQrNAyUbjko4e9upiTWdhLKSMaJ1f9ynxZMAc/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2015-06-08+14.19.47.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/7806554768468889014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/06/hot-to-use-textinputlayout-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7806554768468889014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7806554768468889014'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/06/hot-to-use-textinputlayout-android.html' title='Hot to use TextInputLayout , Android Support library v22.2'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEgZ82En12xdqylWrNbCuB-kV826JX-tfyErHhUC6LqcA05RhfgmSxxZ0Hg3FVjhHXE1VQptL7uigsu4Yn3YLAseN_GLhudnQ2ADZ7jx_zxQrNAyUbjko4e9upiTWdhLKSMaJ1f9ynxZMAc/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2015-06-08+14.19.47.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-2966143495772876033</id><published>2015-05-29T17:53:00.000+09:00</published><updated>2015-06-10T13:08:34.830+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>Hot to use FloatingActionButton , Android Support library v22.2</title><content type='html'>Google had updated Android Support library!!&lt;br /&gt;
We can use the Design Support Library which include Material Design components.&lt;br /&gt;
&lt;br /&gt;
http://developer.android.com/tools/support-library/index.html&lt;br /&gt;
&lt;br /&gt;
&lt;H4&gt;import library&lt;/H4&gt;
The following code is sample for Android Studio.&lt;br /&gt;
Note : typo in Android Developers site
http://developer.android.com/tools/support-library/features.html#design&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
    compile &#39;com.android.support:design:22.2.0&#39;
&lt;/pre&gt;
&lt;br /&gt;
&lt;H4&gt;FloatingActionButton&lt;/H4&gt;
The following code is sample for Layout.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    &amp;lt;android.support.design.widget.FloatingActionButton
            android:id=&amp;quot;@+id/floating_action_button&amp;quot;
            android:layout_height=&amp;quot;wrap_content&amp;quot;
            android:layout_width=&amp;quot;wrap_content&amp;quot;
            android:src=&amp;quot;@drawable/XXXX&amp;quot;
            android.support.design:backgroundTint=&amp;quot;@color/fab_bg&amp;quot;
            android:contentDescription=&amp;quot;@string/XXXX&amp;quot;/&amp;gt;
&lt;/pre&gt;
Default Fab Color is &quot;colorAccent&quot;. If use other color, we can set android.support.design:backgroundTint.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;H4&gt;Note&lt;/H4&gt;
Design Library(ver 22.2) has some issues. &lt;br /&gt;
FAB doesn&#39;t have shadow on Lollipop &lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=175068&quot;&gt;https://code.google.com/p/android/issues/detail?id=175068&lt;/a&gt;&lt;br /&gt;
The FloatingActionButton has different margins on Lollipop and pre-Lollipop. &lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=175330&quot;&gt;https://code.google.com/p/android/issues/detail?id=175330&lt;/a&gt; &lt;br /&gt;
 &lt;br /&gt;
If not show &quot;Shadow&quot;, set &quot;app:borderWidth=&quot;0dp&quot;.</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/2966143495772876033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/05/android-support-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2966143495772876033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2966143495772876033'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/05/android-support-library.html' title='Hot to use FloatingActionButton , Android Support library v22.2'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-8722381486652309484</id><published>2015-04-29T20:39:00.000+09:00</published><updated>2015-04-29T20:41:39.457+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android JUnit Test"/><category scheme="http://www.blogger.com/atom/ns#" term="Espresso"/><title type='text'>How to IntentsTestRule, in AndroidTest</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwR5mlhqnu3hg4qc43Z05WwD9wE7XGaOZCFySDigTxPHcWjtBipXSIzowN_qDhV7zy544QxV89igbu-Kykkt3UjYFdO6v21dJF-ALaRbwDDYwenJEqPdtJUlX4hyoMZqp4PtUzMuVqgX9R/s1600/espresso_lockup.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwR5mlhqnu3hg4qc43Z05WwD9wE7XGaOZCFySDigTxPHcWjtBipXSIzowN_qDhV7zy544QxV89igbu-Kykkt3UjYFdO6v21dJF-ALaRbwDDYwenJEqPdtJUlX4hyoMZqp4PtUzMuVqgX9R/s320/espresso_lockup.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;


&lt;h4&gt;About IntentsTestRule&lt;/h4&gt;
IntentsTestRule is AndroidTest which can do intent test.&lt;br /&gt;
&lt;br /&gt;
If use, we have to add Espresso-Intents library in build.gradle.&lt;br /&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
    androidTestCompile &#39;com.android.support.test.espresso:espresso-intents:2.1&#39;
&lt;/pre&gt;


&lt;h4&gt;Test Sample&lt;/h4&gt;
The following code is sample which Intent has Intent.ACTION_CALL by user operation.&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityIntentTest {

    @Rule
    public IntentsTestRule&amp;lt;MainActivity&amp;gt; mActivityRule = new IntentsTestRule&amp;lt;&amp;gt;(
            MainActivity.class);

    @Before
    public void stubAllExternalIntents() {
        // By default Espresso Intents does not stub any Intents. Stubbing needs to be setup before
        // every test run. In this case all external Intents will be blocked.
        intending(not(isInternal()))
                .respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, null));
    }

    @Test
    public void callPhone() {
        // call action
        onView(withId(R.id.callButton)).perform(click());

        // test
        intended(allOf(
                hasAction(Intent.ACTION_CALL),
                hasData(&amp;quot;tel:0123456789&amp;quot;),
                toPackage(&amp;quot;com.android.server.telecom&amp;quot;)));

    }
}
&lt;/pre&gt;

How to create test class.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;create test class with RunWith annotation &lt;/li&gt;
&lt;li&gt;add IntentsTestRule with Rule annotation &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;

We can check whether Intent has occurred.&lt;br /&gt;
&lt;li&gt;Intended method which check the intended Intent&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.android.com/reference/android/support/test/espresso/intent/matcher/IntentMatchers.html&quot;&gt;matches method&lt;/a&gt;&lt;/li&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Add Intent to Starting Activity&lt;/h4&gt;
If need to add Intent to Activity, we need to do override IntentsTestRule#getActivityIntent.
&lt;pre class=&quot;brush: java;&quot;&gt;
    @Rule
    public IntentsTestRule&amp;lt;MainActivity&amp;gt; mActivityRule = new IntentsTestRule&amp;lt;&amp;gt;(MainActivity.class) {

        /**
        * add Intent to Activity
        */
        @Override
        protected Intent getActivityIntent() {
            Intent intent = new Intent();
            intent.putExtra(KEY_DATA,data);
            return intent;
        }
    };
&lt;/pre&gt;

&lt;br /&gt;
&lt;a href=&quot;https://github.com/googlesamples/android-testing&quot;&gt;https://github.com/googlesamples/android-testing&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/8722381486652309484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/04/how-to-intentstestrule-in-androidtest.html#comment-form' title='170 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8722381486652309484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8722381486652309484'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/04/how-to-intentstestrule-in-androidtest.html' title='How to IntentsTestRule, in AndroidTest'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEgwR5mlhqnu3hg4qc43Z05WwD9wE7XGaOZCFySDigTxPHcWjtBipXSIzowN_qDhV7zy544QxV89igbu-Kykkt3UjYFdO6v21dJF-ALaRbwDDYwenJEqPdtJUlX4hyoMZqp4PtUzMuVqgX9R/s72-c/espresso_lockup.png" height="72" width="72"/><thr:total>170</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-963924804558298774</id><published>2015-03-01T16:21:00.001+09:00</published><updated>2015-03-01T16:23:17.404+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android JUnit Test"/><category scheme="http://www.blogger.com/atom/ns#" term="Espresso"/><title type='text'>How to check Toast window, on android test-kit Espresso</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/AVvXsEhARs4avsNsmy1znVk89T-yNtLi7Gsa1-vH3H0JtnVsPiqF_oom3qOLhHEZ0wxRAipcIIsz8TBnUsle5AxuZpxDFo49CRV5my_IWX_k24gBS8cJJFtH0lUDCKhD6rlPpZsklmvc4nuLvjhq/s1600/espresso_lockup.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/AVvXsEhARs4avsNsmy1znVk89T-yNtLi7Gsa1-vH3H0JtnVsPiqF_oom3qOLhHEZ0wxRAipcIIsz8TBnUsle5AxuZpxDFo49CRV5my_IWX_k24gBS8cJJFtH0lUDCKhD6rlPpZsklmvc4nuLvjhq/s320/espresso_lockup.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
If we read the following public document, we can check other window.&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/android-test-kit/wiki/EspressoSamples#Using_inRoot_to_target_non-default_windows&quot;&gt;Using inRoot to target non-default windows&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
onView(withText(&quot;South China Sea&quot;))
  .inRoot(withDecorView(not(is(getActivity().getWindow().getDecorView()))))
  .perform(click());
&lt;/pre&gt;&lt;br /&gt;
But, I think this is not cool.&lt;br /&gt;
&lt;br /&gt;
We can create a custom matcher.&lt;br /&gt;
Toast window has the WindowManager.LayoutParams.TYPE_TOAST.&lt;br /&gt;
&lt;br /&gt;
The followinf code is sample.&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    /**
     * Matcher that is Toast window.
     */
    public static Matcher&amp;lt;Root&amp;gt; isToast() {
        return new TypeSafeMatcher&amp;lt;Root&amp;gt;() {

            @Override
            public void describeTo(Description description) {
                description.appendText(&amp;quot;is toast&amp;quot;);
            }

            @Override
            public boolean matchesSafely(Root root) {
                int type = root.getWindowLayoutParams().get().type;
                if ((type == WindowManager.LayoutParams.TYPE_TOAST)) {
                    IBinder windowToken = root.getDecorView().getWindowToken();
                    IBinder appToken = root.getDecorView().getApplicationWindowToken();
                    if (windowToken == appToken) {
                        // windowToken == appToken means this window isn&amp;#039;t contained by any other windows.
                        // if it was a window for an activity, it would have TYPE_BASE_APPLICATION.
                        return true;
                    }
                }
                return false;
            }
        };
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/963924804558298774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/03/how-to-check-toast-window-on-android.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/963924804558298774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/963924804558298774'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/03/how-to-check-toast-window-on-android.html' title='How to check Toast window, on android test-kit Espresso'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEhARs4avsNsmy1znVk89T-yNtLi7Gsa1-vH3H0JtnVsPiqF_oom3qOLhHEZ0wxRAipcIIsz8TBnUsle5AxuZpxDFo49CRV5my_IWX_k24gBS8cJJFtH0lUDCKhD6rlPpZsklmvc4nuLvjhq/s72-c/espresso_lockup.png" height="72" width="72"/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-6469050208716432807</id><published>2015-02-09T23:38:00.001+09:00</published><updated>2015-02-09T23:40:31.138+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use Code Coverage at Android Studio</title><content type='html'>&lt;h4&gt;How to set the Code Coverage in build.gradle &lt;/h4&gt;
We need to add &quot;testCoverageEnabled&quot;. The following build.gradle is sample.&lt;br/&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush: diff;&quot;&gt;
android {
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;), &#39;proguard-rules.txt&#39;
        }

+        debug {
+            testCoverageEnabled = true
+        }
    }
}
&lt;/pre&gt;
&lt;br/&gt;
&lt;h4&gt;How to excute Code Coverage&lt;/h4&gt;
We need to excute Code Coverage from terminal.&lt;br/&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;
./gradlew createDebugCoverageReport
&lt;/pre&gt;
&lt;br/&gt;
When excute Code Coverage, automatically Gradle run the androidTest.&lt;br/&gt;
If not connected device(or Emulator), you shold show the following error.&lt;br/&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;
:app:connectedAndroidTest FAILED          
              
FAILURE: Build failed with an exception.
              
* What went wrong:
Execution failed for task &#39;:app:connectedAndroidTest&#39;.
&gt; com.android.builder.testing.api.DeviceException: java.lang.RuntimeException: No connected devices!
&lt;/pre&gt;
&lt;br/&gt;
We need to connect device or wake up Emulator.&lt;br/&gt;
&lt;br/&gt;
&lt;h4&gt;How to show the Code Covoerage Report&lt;/h4&gt;
If successed createDebugCoverageReport、Gradle saved report in the following path.&lt;br /&gt;
[PROJECT]/app/build/outputs/reports/coverage/debug/index.html&lt;br /&gt;
&lt;br /&gt;
We can investigate the none test Line.&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/AVvXsEhUFDpDhZ6VPLWkryvLIQ18F1Y86xisXGonLnR8CQkWE0pbVYxdcXrZiM5Z0J0nbl9DSBXnw7VjAMngoHbWUVyPIWSet_v9Gu-zj8cWCJuSGoHtF1JQUAHcWSz6niYPH0-018QytVYywq0/s1600/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88+2015-02-08+12.29.47.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/AVvXsEhUFDpDhZ6VPLWkryvLIQ18F1Y86xisXGonLnR8CQkWE0pbVYxdcXrZiM5Z0J0nbl9DSBXnw7VjAMngoHbWUVyPIWSet_v9Gu-zj8cWCJuSGoHtF1JQUAHcWSz6niYPH0-018QytVYywq0/s400/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88+2015-02-08+12.29.47.png&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/AVvXsEh72QcaVAGkJzZ5b4cTX802og4_HyJBPiTpE0oXg3njyqZu-U1sDIFQBGjsAnBSQXlwUqOx28rHLGWGLEZUz_TIUOvGtRsx7-_CifiAijRIUe8yvjGe9HzncnbWliI5CJbo-w923q2Bq3M/s1600/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88+2015-02-08+12.33.30.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/AVvXsEh72QcaVAGkJzZ5b4cTX802og4_HyJBPiTpE0oXg3njyqZu-U1sDIFQBGjsAnBSQXlwUqOx28rHLGWGLEZUz_TIUOvGtRsx7-_CifiAijRIUe8yvjGe9HzncnbWliI5CJbo-w923q2Bq3M/s400/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88+2015-02-08+12.33.30.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/6469050208716432807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/02/how-to-use-code-coverage-at-android.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6469050208716432807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6469050208716432807'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/02/how-to-use-code-coverage-at-android.html' title='How to use Code Coverage at Android Studio'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEhUFDpDhZ6VPLWkryvLIQ18F1Y86xisXGonLnR8CQkWE0pbVYxdcXrZiM5Z0J0nbl9DSBXnw7VjAMngoHbWUVyPIWSet_v9Gu-zj8cWCJuSGoHtF1JQUAHcWSz6niYPH0-018QytVYywq0/s72-c/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88+2015-02-08+12.29.47.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-8088928708547210978</id><published>2015-01-21T01:10:00.000+09:00</published><updated>2015-01-21T01:10:57.116+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android JUnit Test"/><title type='text'>IllegalStateException at ActivityUnitTestCase with ActionBarActivity</title><content type='html'>I need to do ActivityUnitTestCase which activity is extends ActionBarActivity.&lt;/br&gt;
However, I get the following exception.&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
If call startActivity, Context does not have Theme.AppCompat...&lt;/br&gt;
So, We need to call setActivityContext() due to set Context with theme.&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        Context context = getInstrumentation().getTargetContext();
        ContextThemeWrapper contextTheme = new ContextThemeWrapper(context, R.style.AppTheme);
        setActivityContext(contextTheme);
        startActivity(new Intent(), null, null);
    }
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/8088928708547210978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/01/illegalstateexception-at.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8088928708547210978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8088928708547210978'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/01/illegalstateexception-at.html' title='IllegalStateException at ActivityUnitTestCase with ActionBarActivity'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-2966483412838606994</id><published>2015-01-17T23:27:00.000+09:00</published><updated>2015-01-17T23:27:30.405+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to add Volley Request with parameter of POST and Headers</title><content type='html'>If need to add parameter of POST and Headers, you need to read the following source code.&lt;/br&gt;
There are getHeaders() and getParams() in &lt;a href=&quot;https://android.googlesource.com/platform/frameworks/volley/+/master/src/main/java/com/android/volley/Request.java&quot;&gt;Request class&lt;/a&gt; which is super class of StringRequest class. 
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
     /**
     * Returns a list of extra HTTP headers to go along with this request. Can
     * throw {@link AuthFailureError} as authentication may be required to
     * provide these values.
     * @throws AuthFailureError In the event of auth failure
     */
    public Map&amp;lt;String, String&amp;gt; getHeaders() throws AuthFailureError {
        return Collections.emptyMap();
    }

     /**
     * Returns a Map of parameters to be used for a POST or PUT request.  Can throw
     * {@link AuthFailureError} as authentication may be required to provide these values.
     *
     * &amp;lt;p&amp;gt;Note that you can directly override {@link #getBody()} for custom data.&amp;lt;/p&amp;gt;
     *
     * @throws AuthFailureError in the event of auth failure
     */
    protected Map&amp;lt;String, String&amp;gt; getParams() throws AuthFailureError {
        return null;
    }
&lt;/pre&gt;
&lt;/br&gt;
We can add parameter when do override getHeaders() and getParams() method.The following source is sample.&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    /**
     * Request(StringRequest) with params
     *
     * @param url      request url
     * @param listener listener for Response or Error
     * @param params   value of setting Http Params
     * @param headers  value of setting Http headers
     */
    public void get(String url, final ResponseListener listener, final Map&amp;lt;String, String&amp;gt; params
            , final Map&amp;lt;String, String&amp;gt; headers) {
 
        StringRequest request = new StringRequest(url,
                new Response.Listener&amp;lt;String&amp;gt;() {
                    @Override
                    public void onResponse(String s) {
                        listener.onResponse(s);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        listener.onErrorResponse(volleyError);
                    }
                }
        ) {
            @Override
            protected Map&amp;lt;String, String&amp;gt; getParams() throws AuthFailureError {
                return params;
            }
 
            @Override
            public Map&amp;lt;String, String&amp;gt; getHeaders() throws AuthFailureError {
                return headers;
            }
        };
 
        mRequestQueue.add(request);
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/2966483412838606994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/01/how-to-add-volley-request-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2966483412838606994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2966483412838606994'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2015/01/how-to-add-volley-request-with.html' title='How to add Volley Request with parameter of POST and Headers'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-1001836615229573560</id><published>2014-07-27T18:15:00.000+09:00</published><updated>2015-01-17T21:52:01.491+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to handle to auto flip with ViewFlipper</title><content type='html'>ViewFlipper do not have a handler to auto flipping.&lt;br /&gt;
If do handing, we should get Animation Class via VewFlipper#getInAnimation().&lt;br /&gt;
We register to Listener.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The follow code is sample.
&lt;pre class=&quot;brush: java;&quot;&gt;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_flashing_card, null);
        mVewFlipper = (ViewFlipper) view.findViewById(R.id.viewFlipper1);

        mVewFlipper.setAutoStart(true);
        mVewFlipper.setInAnimation(getActivity(), android.R.anim.slide_in_left);
        mVewFlipper.getInAnimation().setAnimationListener(this);
        mVewFlipper.setFlipInterval(2000);

        return view;
    }

    @Override
    public void onAnimationEnd(Animation animation) {
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }

    @Override
    public void onAnimationStart(Animation animation) {
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/1001836615229573560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/07/how-to-handle-to-auto-flip-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1001836615229573560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1001836615229573560'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/07/how-to-handle-to-auto-flip-with.html' title='How to handle to auto flip with ViewFlipper'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-1560323970720361953</id><published>2014-03-30T01:24:00.001+09:00</published><updated>2015-01-17T21:52:54.464+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use SwipeRefreshLayout, like a twitter, facebook</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/AVvXsEgBxrGGJVm8MMmrnfc5-OPcx094NPdmnB8aa9eC5ScVKxzIXA1L6di70jzwAZCFiW47FfZgk7Lw2bIEwEfIVUKEWNkgPfqIoOHrNsz4wUi0y-k65g90mhwd-TrDTAWYcbzI8lQMp0dZdJke/s1600/device-2014-04-03-084228.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/AVvXsEgBxrGGJVm8MMmrnfc5-OPcx094NPdmnB8aa9eC5ScVKxzIXA1L6di70jzwAZCFiW47FfZgk7Lw2bIEwEfIVUKEWNkgPfqIoOHrNsz4wUi0y-k65g90mhwd-TrDTAWYcbzI8lQMp0dZdJke/s400/device-2014-04-03-084228.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;h4&gt;Create the Layout&lt;/h4&gt;
You need to use the android.support.v4.widget.SwipeRefreshLayout.&lt;br/&gt;
Content is included SwipeRefreshLayout for clild layout( or view). &lt;br/&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush: xml;&quot;&gt;
&amp;lt;android.support.v4.widget.SwipeRefreshLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;
    android:id=&amp;quot;@+id/swipe_refresh_widget&amp;quot;
    android:layout_width=&amp;quot;match_parent&amp;quot;
    android:layout_height=&amp;quot;match_parent&amp;quot;&amp;gt;
    
    &amp;lt;!-- some full screen pullable view that will be the offsetable content --&amp;gt;

    &amp;lt;ListView
        android:layout_width=&amp;quot;match_parent&amp;quot;
        android:layout_height=&amp;quot;match_parent&amp;quot;
        android:id=&amp;quot;@+id/content&amp;quot;/&amp;gt;
&amp;lt;/android.support.v4.widget.SwipeRefreshLayout&amp;gt;
&lt;/pre&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;h4&gt;Update for Swipe&lt;/h4&gt;
You need the following step, due to updating for Swipe.&lt;br/&gt;
1. call setOnRefreshListener methiod due to setting Listener which handles the update starting.&lt;br/&gt;
2. onRefresh() is handled the update starting.&lt;br/&gt;
3. Then your update process finish、call setRefreshing(false).&lt;br/&gt;

&lt;pre class=&quot;brush: java;&quot;&gt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sample_swipe_refresh_widget);
        mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_widget);
        mSwipeRefreshLayout.setOnRefreshListener(this);
    }
&lt;/pre&gt;

&lt;br/&gt;&lt;br/&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    @Override
    public void onRefresh() {
        refresh();
    }

    private void refresh() {
        Message msg = mHander.obtainMessage(0, this);
        mHander.sendMessageDelayed(msg, 1000);
    }

    private static Handler mHander = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            SwipeRefreshLayoutActivity actibity = (SwipeRefreshLayoutActivity) msg.obj;
            actibity.mSwipeRefreshLayout.setRefreshing(false);
        }
    };
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/1560323970720361953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/03/how-to-use-swiperefreshlayout-like.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1560323970720361953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1560323970720361953'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/03/how-to-use-swiperefreshlayout-like.html' title='How to use SwipeRefreshLayout, like a twitter, facebook'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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/AVvXsEgBxrGGJVm8MMmrnfc5-OPcx094NPdmnB8aa9eC5ScVKxzIXA1L6di70jzwAZCFiW47FfZgk7Lw2bIEwEfIVUKEWNkgPfqIoOHrNsz4wUi0y-k65g90mhwd-TrDTAWYcbzI8lQMp0dZdJke/s72-c/device-2014-04-03-084228.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-7279374456404735563</id><published>2014-03-15T19:46:00.001+09:00</published><updated>2015-01-17T21:53:49.155+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use Google Play services</title><content type='html'>&lt;h3&gt;&lt;a id=&quot;h4-1-1&quot;&gt;&lt;/a&gt;Ready to use Google Play services&lt;/h3&gt;
&lt;p&gt;If you need to use Google Play services API, you should do download of Google Play services on Android SDK Manager.Google Play services was saved in following directory.&amp;lt;AndroidSDK&amp;gt;\sdk\extras\google\google_play_services\libproject\google-play-services_lib&lt;/p&gt;
&lt;p&gt;Importing this Android Project to eclipse.&lt;/p&gt;
&lt;p&gt;You must write a meta-data in AndroidMaifest.xml using Google Play services API.&lt;/p&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;    &amp;lt;application
        &amp;lt;meta-data
            android:name=&amp;quot;com.google.android.gms.version&amp;quot;
            android:value=&amp;quot;@integer/google_play_services_version&amp;quot; /&amp;gt;
    &amp;lt;/application&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;&lt;a id=&quot;h4-1-2&quot;&gt;&lt;/a&gt;Check to exist of Google Play services&lt;/h3&gt;
&lt;p&gt;You shoud Check to exist of Google Play services in a device.&lt;/p&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
public class UsingGooglePlayServiceSampleActivity extends FragmentActivity {

    private boolean isGooglePlayServicesAvailable() {
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

        if (ConnectionResult.SUCCESS == resultCode) {
            return true;
        } else {
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                    CONNECTION_FAILURE_RESOLUTION_REQUEST);
            if (dialog != null) {
                ErrorDialogFragment errorFragment = new ErrorDialogFragment();
                errorFragment.setDialog(dialog);
                errorFragment.show(getSupportFragmentManager(), &amp;quot;errro_dialog&amp;quot;);
            }
        }

        return false;
    }

    public static class ErrorDialogFragment extends DialogFragment {

        private Dialog mDialog;

        public ErrorDialogFragment() {
            super();
            mDialog = null;
        }

        public void setDialog(Dialog dialog) {
            mDialog = dialog;
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            return mDialog;
        }

        @Override
        public void onDestroy() {
            mDialog = null;
            super.onDestroy();
        }
    }
}
&lt;/pre&gt;
&lt;p&gt;Calling a method of GooglePlayServicesUtil.isGooglePlayServicesAvailable(), you can get Result code.If Result code is error, you can get a Dialog Object from calling method GooglePlayServicesUtil.getErrorDialog().You must use a DialogFragment to show a dialog.&lt;/p&gt;
&lt;p&gt;If User close a dialog, onActivityResult is called with Result Code.&lt;/p&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CONNECTION_FAILURE_RESOLUTION_REQUEST) {
            if (resultCode == Activity.RESULT_OK) {
                // retry process
            }
        }
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/7279374456404735563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/03/how-to-use-google-play-services.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7279374456404735563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/7279374456404735563'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/03/how-to-use-google-play-services.html' title='How to use Google Play services'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-1397160912928832748</id><published>2014-02-08T17:58:00.001+09:00</published><updated>2014-02-25T09:05:20.156+09:00</updated><title type='text'>About a permission &quot;WRITE_EXTERNAL_STORAGE&quot;</title><content type='html'>&lt;a href=&quot;http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE&quot;&gt;http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE&lt;/a&gt;
&lt;br /&gt;
&lt;blockquote&gt;
Starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by getExternalFilesDir(String) and getExternalCacheDir()&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
If appliction is waking up on Android 4.4 Device, WRITE_EXTERNAL_STORAGE is not required to call getExternalFilesDir(String) and getExternalCacheDir(). Not returned Null.&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/1397160912928832748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/02/about-permission-writeexternalstorage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1397160912928832748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1397160912928832748'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/02/about-permission-writeexternalstorage.html' title='About a permission &quot;WRITE_EXTERNAL_STORAGE&quot;'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-1444857322168114652</id><published>2014-02-01T00:00:00.000+09:00</published><updated>2015-01-17T21:54:26.460+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>Add &quot;disable swipe&quot; to ViewPager.</title><content type='html'>I want to stop swipe in ViewPager. But ViewPager does not have &quot;disable swipe&quot; API.&lt;/br&gt;
&lt;/br&gt;
&lt;H4&gt;Creat a custom ViewPager&lt;/H4&gt;
I creat a custom ViewPager. Custom ViewPager has a &quot;disable swipe&quot; API.&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
package jp.baroqueworksdev.myapidemo.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class MyViewPager extends ViewPager {
    private boolean mIsEnabledSwipe = true;

    public MyViewPager(Context context) {
        super(context);
    }

    public MyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (!mIsEnabledSwipe) {
            return false;
        }
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (!mIsEnabledSwipe) {
            return false;
        }
        return super.onInterceptTouchEvent(event);
    }

    public void setEnabledSwipe(boolean enabled) {
        mIsEnabledSwipe = enabled;
    }

}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/1444857322168114652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/02/add-disable-swipe-to-viewpager.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1444857322168114652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/1444857322168114652'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2014/02/add-disable-swipe-to-viewpager.html' title='Add &quot;disable swipe&quot; to ViewPager.'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-6596260215961177832</id><published>2013-12-28T00:00:00.000+09:00</published><updated>2015-01-17T21:54:47.933+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use a Sensor of &quot;TYPE_STEP_DETECTOR&quot;</title><content type='html'>A sensor of this type triggers an event each time a step is taken by the user.&lt;/br&gt;
&lt;/br&gt;
&lt;a href=&quot;http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_DETECTOR&quot;&gt;http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_DETECTOR&lt;/a&gt;&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h4&gt;Initialize Sensor&lt;/h4&gt;
We have to get a Sensor&#39;s Object from SensorManager.&lt;/br&gt;
Set the type &quot;Sensor.TYPE_STEP_DETECTOR&quot;.&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
public class StepCounterActivity extends Activity {
    private SensorManager mSensorManager;
    private Sensor mStepSensor;
    private TextView mTextView;

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

        mTextView = (TextView) findViewById(R.id.text_step);

        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);

    }

    protected void onResume() {
        super.onResume();
        mSensorManager.registerListener(mSensorEventListener, mStepSensor,
                SensorManager.SENSOR_DELAY_NORMAL);
    }

    protected void onPause() {
        super.onPause();
        mSensorManager.unregisterListener(mSensorEventListener);
    }
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h4&gt;Create a SensorListener&lt;/h4&gt;
We can get a trigger from onSensorChanged.&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    private SensorEventListener mSensorEventListener = new SensorEventListener() {
        private int mStep;

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        }

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (event.values[0] == 1.0f) {
                mStep++;
            }
            mTextView.setText(Integer.toString(mStep));
        }
    };
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/6596260215961177832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-sensor-of-typestepdetector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6596260215961177832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/6596260215961177832'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-sensor-of-typestepdetector.html' title='How to use a Sensor of &quot;TYPE_STEP_DETECTOR&quot;'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-3220863490120363413</id><published>2013-12-27T00:00:00.000+09:00</published><updated>2015-01-17T21:55:04.116+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use a Sensor of  &quot;TYPE_STEP_COUNTER&quot;</title><content type='html'>Android API 19 add Sensor of &quot;TYPE_STEP_COUNTER&quot;.&lt;/br&gt;
&lt;/br&gt;
&lt;a href=&quot;http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER&quot;&gt;http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER&lt;/a&gt;&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h4&gt;Initialize Sensor&lt;/h4&gt;
We have to get a Sensor&#39;s Object from SensorManager.&lt;/br&gt;
Set the type &quot;Sensor.TYPE_STEP_COUNTER&quot;.&lt;/br&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
public class StepCounterActivity extends Activity {
    private SensorManager mSensorManager;
    private Sensor mStepSensor;
    private TextView mTextView;

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

        mTextView = (TextView) findViewById(R.id.text_step);

        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);

    }

    protected void onResume() {
        super.onResume();
        mSensorManager.registerListener(mSensorEventListener, mStepSensor,
                SensorManager.SENSOR_DELAY_NORMAL);
    }

    protected void onPause() {
        super.onPause();
        mSensorManager.unregisterListener(mSensorEventListener);
    }
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h4&gt;Create a SensorListener&lt;/h4&gt;
We can get a step from onSensorChanged.&lt;/br&gt;
&quot;event.values[0]&quot; is a step counter.A sensor of this type returns the number of steps taken by the user since the last reboot while activated. The value is returned as a float (with the fractional part set to zero) and is reset to zero only on a system reboot. &lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    private SensorEventListener mSensorEventListener = new SensorEventListener() {
        private float mStepOffset;

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        }

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (mStepOffset == 0) {
                mStepOffset = event.values[0];
            }
            mTextView.setText(Float.toString(event.values[0] - mStepOffset));
        }
    };
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/3220863490120363413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-sensor-of-typestepcounter.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3220863490120363413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3220863490120363413'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-sensor-of-typestepcounter.html' title='How to use a Sensor of  &quot;TYPE_STEP_COUNTER&quot;'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7548542647492673021.post-2409481974803941550</id><published>2013-12-21T00:00:00.000+09:00</published><updated>2015-01-17T21:55:22.466+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android App Developer"/><title type='text'>How to use the DrawerLayout like a slide menu of the &quot;Google Play&quot; </title><content type='html'>&lt;h4&gt;
Android Developers Site&lt;/h4&gt;
&lt;a href=&quot;http://developer.android.com/training/implementing-navigation/nav-drawer.html&quot;&gt;http://developer.android.com/training/implementing-navigation/nav-drawer.html&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Creat a layout file&lt;/h4&gt;
You shoud create a layout file using DrawerLayout in android.support.v4.widget.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;android.support.v4.widget.DrawerLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:id=&quot;@+id/drawer_layout&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot; &amp;gt;

    &amp;lt;!-- The main content view --&amp;gt;

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

    &amp;lt;!-- The navigation drawer --&amp;gt;

    &amp;lt;ListView
        android:id=&quot;@+id/left_drawer&quot;
        android:layout_width=&quot;240dp&quot;
        android:layout_height=&quot;match_parent&quot;
        android:layout_gravity=&quot;start&quot;
        android:background=&quot;#111&quot;
        android:choiceMode=&quot;singleChoice&quot;
        android:divider=&quot;@android:color/transparent&quot;
        android:dividerHeight=&quot;0dp&quot; /&amp;gt;

&amp;lt;/android.support.v4.widget.DrawerLayout&amp;gt;
&lt;/pre&gt;
&lt;h4&gt;
Set in Activity&lt;/h4&gt;
We set ActionBarDrawerToggle.&lt;br /&gt;
We call &quot;setHomeButtonEnabled(true)&quot; and &quot;setDisplayHomeAsUpEnabled(true)&quot;, in order to enable the click of an icon on ActionBar.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawerlayout);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        mTitle = getTitle();
        mDrawerTitle = getText(R.string.drawer_open);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(
                this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer, /* nav drawer icon to replace &#39;Up&#39; caret */
                R.string.drawer_open, /* &quot;open drawer&quot; description */
                R.string.drawer_close /* &quot;close drawer&quot; description */
                ) {

                    /**
                     * Called when a drawer has settled in a completely closed
                     * state.
                     */
                    public void onDrawerClosed(View view) {
                        getActionBar().setTitle(mTitle);
                    }

                    /**
                     * Called when a drawer has settled in a completely open
                     * state.
                     */
                    public void onDrawerOpened(View drawerView) {
                        getActionBar().setTitle(mDrawerTitle);
                    }
                };

        // Set the drawer toggle as the DrawerListener
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/2409481974803941550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-drawerlayout-like-slide-menu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2409481974803941550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/2409481974803941550'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/how-to-use-drawerlayout-like-slide-menu.html' title='How to use the DrawerLayout like a slide menu of the &quot;Google Play&quot; '/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-8614984685067595409</id><published>2013-12-06T01:00:00.000+09:00</published><updated>2013-12-07T09:14:18.012+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BeagleBoneBlack"/><title type='text'>Add OpenGL with hardware rendering on JellybeanOnBeaglebone_WithSGX for Beagle Bone Black</title><content type='html'>If you would like to use OpenGL ES 2.0 with hardware rendering, you should add modification.&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;h5&gt;Mod egl.cfg&lt;/h5&gt;
\device\ti\beagleboard\egl.cfg&lt;/br&gt;
&lt;/br&gt;
0 0 android&lt;/br&gt;
0 1 POWERVR_SGX530_125  &lt;- add line !!&lt;/br&gt;
&lt;/br&gt;

&lt;h5&gt;Mod build.prop&lt;/h5&gt;
\device\ti\beagleboard\beagleboard.mk&lt;/br&gt;
&lt;/br&gt;
PRODUCT_PROPERTY_OVERRIDES := \&lt;/br&gt;
        net.dns1=8.8.8.8 \&lt;/br&gt;
        net.dns2=8.8.4.4 \&lt;/br&gt;
        ro.opengles.version=131072   &lt;- add line !!&lt;/br&gt;</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/8614984685067595409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/add-opengl-with-hardware-rendering-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8614984685067595409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/8614984685067595409'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/add-opengl-with-hardware-rendering-on.html' title='Add OpenGL with hardware rendering on JellybeanOnBeaglebone_WithSGX for Beagle Bone Black'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-5037434778990275582</id><published>2013-12-06T00:00:00.000+09:00</published><updated>2015-01-17T21:56:08.856+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BeagleBoneBlack"/><title type='text'>Building JellybeanOnBeaglebone_WithSGX for Beagle Bone Black</title><content type='html'>&lt;h5&gt;Get the Files&lt;/h5&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
  $ repo init -u git://gitorious.org/rowboat/manifest.git -m rowboat-jb-am335x.xml
  $ repo sync $
&lt;/pre&gt;
&lt;/br&gt;
&lt;h5&gt;Toolchain Setup&lt;/h5&gt;
Setup the tool-chain path to point to arm-eabi- tools in prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/&lt;br&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
  $ export PATH=&lt;android source&gt;/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
&lt;/pre&gt;

&lt;h5&gt;Build Boot Loader (MLO/u-boot)&lt;/h5&gt;
Change directory to u-boot&lt;/br&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
  $ cd u-boot
&lt;/pre&gt;
Execute following commands&lt;/br&gt;
&lt;pre class=&quot;brush: shell;&quot;&gt;
  $ make CROSS_COMPILE=arm-eabi- distclean
  $ make CROSS_COMPILE=arm-eabi- am335x_evm_config
  $ make CROSS_COMPILE=arm-eabi- 
&lt;/pre&gt;
Build Android, Kernel and SGX
&lt;pre class=&quot;prettyprint&quot;&gt;
  $ make TARGET_PRODUCT=beagleboneblack OMAPES=4.x
&lt;/pre&gt;

&lt;h5&gt;Create Root Filesystem Tarball&lt;/h5&gt;
Prepare the root filesystem as follows:&lt;/br&gt;
&lt;pre class=&quot;brush: shell;&quot;&gt;
  $ cd &lt;android source&gt;
  $ make TARGET_PRODUCT=beagleboneblack fs_tarball
&lt;/pre&gt;
&lt;h5&gt;Flash SD Card&lt;/h5&gt;
Copy compiled Images to image folder and create a bootable SD card as follows.&lt;/br&gt;
&lt;pre class=&quot;brush: shell;&quot;&gt;
  $ mkdir image_folder
  $ cd image_folder
  $ cp ../kernel/arch/arm/boot/uImage .
  $ cp ../u-boot/MLO .
  $ cp ../u-boot/u-boot.img .
  $ cp ../external/ti_android_utilities/am335x/u-boot-env/uEnv_beagleboneblack.txt .
  $ cp ../out/target/product/beagleboneblack/rootfs.tar.bz2 .
  $ cp ../external/ti_android_utilities/am335x/mk-mmc/mkmmc-android.sh .
  $ sudo ./mkmmc-android.sh YOUR_SD_CARD MLO u-boot.img uImage uEnv_beagleboneblack.txt rootfs.tar.bz2
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/5037434778990275582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/building-jellybeanonbeaglebonewithsgx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/5037434778990275582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/5037434778990275582'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/building-jellybeanonbeaglebonewithsgx.html' title='Building JellybeanOnBeaglebone_WithSGX for Beagle Bone Black'/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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-7548542647492673021.post-3352468361525426666</id><published>2013-12-05T00:00:00.000+09:00</published><updated>2013-12-05T00:00:09.145+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BeagleBoneBlack"/><title type='text'>TI official image of Android On Beagle Bone Black </title><content type='html'>You can get &#39;release information&#39; of Beagle Bone Black&#39;s Android.&lt;/br&gt;
http://downloads.ti.com/sitara_android/esd/TI_Android_DevKit/TI_Android_JB_4_2_2_DevKit_4_1_1/index_FDS.html&lt;/br&gt;
&lt;/br&gt;
I got offical TI image Of Android 4.2.2, and install to beagle bone black.&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
$ wget http://downloads.ti.com/sitara_android/esd/TI_Android_DevKit/TI_Android_JB_4_2_2_DevKit_4_1_1/exports/TI_Android_JB_4.2.2_DevKit_4.1.1_beagleboneblack.tar.gz
$ tar xzvf TI_Android_JB_4.2.2_DevKit_4.1.1_beagleboneblack.tar.gz
$ cd beagleboneblack
$ sudo ./mkmmc-android.sh /dev/&lt;YOUR_SD_MOUNT_NAME&gt;
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
copyed to log.
&lt;/br&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
Assuming Default Locations for Prebuilt Images
All data on /dev/sdb now will be destroyed! Continue? [y/n]
y
[Unmounting all existing partitions on the device ]
umount: /dev/sdb: not mounted
umount: /dev/sdb2: not mounted
[Partitioning /dev/sdb...]
Disk /dev/sdb doesn&#39;t contain a valid partition table
DISK SIZE - 7851737088 bytes
CYLINDERS - 954
[Making filesystems...]
[Copying files...]
[Copying START_HERE folder to boot partition]
umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[Copying all clips to data partition]
[Done]
&lt;/pre&gt;
&lt;/br&gt;
&lt;/br&gt;
Takes a long time to start Android...Please wait 10 minutes.</content><link rel='replies' type='application/atom+xml' href='http://baroqueworksdev.blogspot.com/feeds/3352468361525426666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/ti-official-image-of-android-on-beagle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3352468361525426666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7548542647492673021/posts/default/3352468361525426666'/><link rel='alternate' type='text/html' href='http://baroqueworksdev.blogspot.com/2013/12/ti-official-image-of-android-on-beagle.html' title='TI official image of Android On Beagle Bone Black '/><author><name>baroqueworkdev</name><uri>http://www.blogger.com/profile/05590925357596481434</uri><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>