{"id":523,"date":"2017-09-17T00:42:20","date_gmt":"2017-09-16T15:42:20","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2017\/09\/17\/android_vibrator\/"},"modified":"2017-09-17T00:42:20","modified_gmt":"2017-09-16T15:42:20","slug":"android_vibrator","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2017\/09\/17\/android_vibrator\/","title":{"rendered":"Android Vibrator \u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android-Vibrator-_14F6A\/android_vibrate.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"185\" height=\"329\" title=\"android_vibrate\" style=\"display: inline; background-image: none;\" alt=\"android_vibrate\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android-Vibrator-_14F6A\/android_vibrate_thumb.jpg\" border=\"0\"><\/a><\/p>\n<p><a title=\"https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/8dd1ca93ff33afa73714eeaafedbd71ef052a52c\" href=\"https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/8dd1ca93ff33afa73714eeaafedbd71ef052a52c\">https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/8dd1ca93ff33afa73714eeaafedbd71ef052a52c<\/a><\/p>\n<p>Fragment \u304b\u3089\u3000Vibrator\u3092\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<h2>1.\u30ec\u30a4\u30a2\u30a6\u30c8<\/h2>\n<p>\u30d0\u30a4\u30d6\u30ec\u30fc\u30bf\u30fc\u958b\u59cb\u30dc\u30bf\u30f3\u3001\u7d42\u4e86\u30dc\u30bf\u30f3\u3092\u914d\u7f6e<\/p>\n<pre class=\"prettyprint linenums\">&lt;FrameLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    tools:context=\"info.typea.kaigiutil.SleepDefenderFragment\"&gt;\r\n\r\n\r\n    &lt;LinearLayout\r\n        android:orientation=\"horizontal\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"&gt;\r\n\r\n        &lt;Button\r\n            android:id=\"@+id\/btn_vib_start\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:text=\"START\" \/&gt;\r\n\r\n        &lt;Button\r\n            android:id=\"@+id\/btn_vib_stop\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:text=\"STOP\" \/&gt;\r\n\r\n    &lt;\/LinearLayout&gt;\r\n&lt;\/FrameLayout&gt;\r\n\r\n<\/pre>\n<h2>2.\u30d0\u30a4\u30d6\u30ec\u30fc\u30bf\u30fc\u3092\u958b\u59cb\/\u505c\u6b62\u3059\u308b<\/h2>\n<blockquote>\n<p>HTC Desire 626 \u3067\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u3066\u3044\u306e\u305f\u304c\u3046\u3093\u3068\u3082\u3059\u3093\u3068\u3082\u8a00\u308f\u306a\u3044\u3002\u8a2d\u5b9a\u3082\u304a\u304b\u3057\u304f\u306a\u3055\u305d\u3046\u3060\u3057\u3001\u30b0\u30b0\u3063\u3066\u3082\u4e0d\u5177\u5408\u7684\u306a\u60c5\u5831\u3082\u306a\u3044\u3057\u3001\u3001\u3001<\/p>\n<p>\u3068\u300130\u5206\u304f\u3089\u3044\u9014\u65b9\u306b\u66ae\u308c\u3066\u3044\u305f\u3089\u3001\u7701\u96fb\u529b\u30e2\u30fc\u30c9\u3060\u3068\u3001\u30d0\u30a4\u30d6\u30ec\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u304cOFF\u306b\u306a\u308b\u3088\u3046\u3060\u3002\u7701\u96fb\u529b\u30e2\u30fc\u30c9\u3092\u5207\u3063\u305f\u3089\u52d5\u304d\u307e\u3057\u305f\u3002<\/p>\n<\/blockquote>\n<pre class=\"prettyprint linenums\">package info.typea.kaigiutil;\r\n\r\nimport android.content.Context;\r\nimport android.os.Bundle;\r\nimport android.os.Vibrator;\r\nimport android.support.annotation.Nullable;\r\nimport android.support.v4.app.Fragment;\r\nimport android.view.LayoutInflater;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.Toast;\r\n\r\n\r\npublic class SleepDefenderFragment extends Fragment implements View.OnClickListener {\r\n    private static final String ARG_MSG = \"message\";\r\n    private Vibrator vibrator;\r\n\r\n    public SleepDefenderFragment() {\r\n    }\r\n\r\n    public static SleepDefenderFragment newInstance(String message) {\r\n        SleepDefenderFragment fragment = new SleepDefenderFragment();\r\n        Bundle args = new Bundle();\r\n        args.putString(ARG_MSG, message);\r\n        fragment.setArguments(args);\r\n        return fragment;\r\n    }\r\n\r\n    @Override\r\n    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\r\n        super.onCreateView(inflater, container, savedInstanceState);\r\n        return inflater.inflate(R.layout.fragment_sleep_defender, container, false);\r\n    }\r\n\r\n    @Override\r\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\r\n        super.onViewCreated(view, savedInstanceState);\r\n\r\n        view.findViewById(R.id.btn_vib_start).setOnClickListener(this);\r\n        view.findViewById(R.id.btn_vib_stop).setOnClickListener(this);\r\n\r\n        vibrator = (Vibrator)this.getContext().getSystemService(Context.VIBRATOR_SERVICE);\r\n    }\r\n\r\n    @Override\r\n    public void onClick(View v) {\r\n\r\n        switch(v.getId()) {\r\n            case R.id.btn_vib_start:\r\n\r\n                if (!vibrator.hasVibrator()) {\r\n                    Toast.makeText(this.getContext(), \"no vibrator.\", Toast.LENGTH_LONG).show();\r\n                    return;\r\n                }\r\n                Toast.makeText(this.getContext(), \"start vibe\", Toast.LENGTH_SHORT).show();\r\n                long pattern[] = {1000, 100 };\r\n                int repeatIndex = 0; \/\/ \u7e70\u308a\u8fd4\u3057\u958b\u59cb\u4f4d\u7f6e -1\u306e\u5834\u5408\u7e70\u308a\u8fd4\u3057\u306a\u3057\r\n                vibrator.vibrate(pattern, repeatIndex);\r\n                break;\r\n\r\n            case R.id.btn_vib_stop:\r\n\r\n                vibrator.cancel();\r\n                Toast.makeText(this.getContext(), \"stop vibe\", Toast.LENGTH_SHORT).show();\r\n                break;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p><a href=\"https:\/\/www.amazon.co.jp\/ZenPad%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA-TABLET-Android-7-9inch-Z580CA-WH32\/dp\/B0148KH10E\/ref=as_li_ss_il?s=electronics&amp;ie=UTF8&amp;qid=1505576413&amp;sr=1-4&amp;keywords=android+zenpad&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=aaa35b903de8bc28df8796d11c179825\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=B0148KH10E&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=B0148KH10E\" border=\"0\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/8dd1ca93ff33afa73714eeaafedbd71ef052a52c Fragment \u304b\u3089\u3000Vibrator\u3092\u8d77\u52d5\u3059\u308b\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[39],"tags":[],"class_list":["post-523","post","type-post","status-publish","format-standard","hentry","category-android"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=523"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/523\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}