{"id":224,"date":"2010-06-21T13:59:36","date_gmt":"2010-06-21T04:59:36","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2010\/06\/21\/androidx06ht_desire_1\/"},"modified":"2010-06-21T13:59:36","modified_gmt":"2010-06-21T04:59:36","slug":"androidx06ht_desire_1","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2010\/06\/21\/androidx06ht_desire_1\/","title":{"rendered":"Android(X06HT Desire) \u9023\u7d61\u5148\u306e\u53d6\u5f97\u3068\u96fb\u8a71\u3092\u304b\u3051\u308b\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u96fb\u8a71\u756a\u53f7\u3092\u5165\u308c\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30c0\u30a4\u30e4\u30eb\u753b\u9762\u306b\u9077\u79fb\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u3002<\/p>\n<p>\u30b3\u30f3\u30bf\u30af\u30c8\u30ea\u30b9\u30c8\u304b\u3089\u3001\u30e6\u30fc\u30b6\u30fcID\u3001\u8868\u793a\u540d\u3001\u96fb\u8a71\u756a\u53f7\u3092\u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\u306b\u8868\u793a\u3057\u3001\u9078\u629e\u3055\u308c\u305f\u3089\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u96fb\u8a71\u756a\u53f7\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AndroidX06HTDesire_BD47\/telephone.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"telephone\" border=\"0\" alt=\"telephone\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AndroidX06HTDesire_BD47\/telephone_thumb.jpg\" width=\"244\" height=\"184\"><\/a>&nbsp;<\/p>\n<pre class=\"prettyprint linenums\">package info.typea.telephoneapp;\r\n\r\nimport android.app.ListActivity;\r\nimport android.content.Intent;\r\nimport android.database.Cursor;\r\nimport android.net.Uri;\r\nimport android.os.Bundle;\r\nimport android.provider.ContactsContract;\r\nimport android.view.View;\r\nimport android.view.View.OnClickListener;\r\nimport android.widget.Button;\r\nimport android.widget.EditText;\r\nimport android.widget.LinearLayout;\r\nimport android.widget.ListView;\r\nimport android.widget.SimpleCursorAdapter;\r\nimport android.widget.TextView;\r\n\r\n\/**\r\n * @see http:\/\/stackoverflow.com\/questions\/1721279\/how-to-read-contacts-on-android-2-0\r\n *\/\r\npublic class TelephoneAppActivity extends ListActivity implements OnClickListener {\r\n    \/** Called when the activity is first created. *\/\r\n    private EditText txtPhoneNo;\r\n    private SimpleCursorAdapter adapter;\r\n    \r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.main);\r\n        \r\n        txtPhoneNo = (EditText)findViewById(R.id.txt_phone_no);\r\n        \r\n        Button btn = (Button)findViewById(R.id.btn_call);\r\n        btn.setOnClickListener(this);\r\n    \r\n        \/\/ \u30ea\u30b9\u30c8\u306b\u8868\u793a\u3059\u308b\u9805\u76ee\r\n        String[] projection = {\r\n                ContactsContract.CommonDataKinds.Phone._ID,\r\n                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,\r\n                ContactsContract.CommonDataKinds.Phone.NUMBER\r\n        };\r\n        String   selection     = null;\r\n        String[] selectionArgs = null;\r\n        String   sortOrder = ContactsContract.PhoneLookup.DISPLAY_NAME + \" asc\";\r\n        \/\/ \u30ab\u30fc\u30bd\u30eb\u306e\u751f\u6210\r\n        Cursor cur = managedQuery(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,\r\n                                  projection, \r\n                                  selection, selectionArgs, sortOrder);\r\n\r\n        \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30ab\u30e9\u30e0\u3068\u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\u306e\u95a2\u9023\u3065\u3051\r\n        String from[] = new String[] { ContactsContract.CommonDataKinds.Phone._ID,\r\n                                       ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,\r\n                                       ContactsContract.CommonDataKinds.Phone.NUMBER };\r\n        int[] to = new int[] { R.id.lbl_id, R.id.lbl_name, R.id.lbl_phone};\r\n     \r\n        \/\/ \u30ea\u30b9\u30c8\u30a2\u30c0\u30d7\u30bf\u306e\u30bb\u30c3\u30c8\r\n        adapter = new SimpleCursorAdapter(this, R.layout.row_phoneno, cur, from, to);\r\n        setListAdapter(adapter);\r\n    }\r\n    \r\n    @Override\r\n    protected void onListItemClick(ListView l, View v, int position, long id) {\r\n        super.onListItemClick(l, v, position, id);\r\n\r\n        LinearLayout ll = (LinearLayout) v;\r\n        TextView phone = (TextView) ll.findViewById(R.id.lbl_phone);\r\n        \r\n        txtPhoneNo.setText(phone.getText());\r\n    }\r\n\r\n    @Override\r\n    public void onClick(View v) {\r\n\r\n        \/\/ \u30c0\u30a4\u30a2\u30eb\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u306b\u9077\u79fb\r\n        String phoneNo = \"tel:\" + txtPhoneNo.getText().toString();\r\n        \r\n        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(phoneNo));\r\n        startActivity(intent);\r\n        \r\n    }\r\n}\r\n<\/pre>\n<h3>\/res\/layout\/main.xml<\/h3>\n<pre class=\"prettyprint linenums\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:orientation=\"vertical\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"&gt;\r\n    &lt;EditText android:text=\"\" \r\n                 android:layout_height=\"wrap_content\" \r\n                 android:layout_width=\"fill_parent\" \r\n                 android:inputType=\"phone\" \r\n                 android:id=\"@+id\/txt_phone_no\"&gt;&lt;\/EditText&gt;\r\n    &lt;Button   android:id=\"@+id\/btn_call\" \r\n                 android:layout_height=\"wrap_content\" \r\n                 android:layout_width=\"fill_parent\" \r\n                 android:text=\"call\"&gt;&lt;\/Button&gt;\r\n    &lt;ListView android:id=\"@+id\/android:list\" \r\n                 android:layout_height=\"wrap_content\" \r\n                 android:layout_width=\"fill_parent\"&gt;&lt;\/ListView&gt;\r\n    &lt;TextView android:text=\"No Contact list.\" \r\n                 android:id=\"@+id\/android:empty\" \r\n                 android:layout_width=\"wrap_content\" \r\n                 android:layout_height=\"wrap_content\"&gt;&lt;\/TextView&gt;\r\n&lt;\/LinearLayout&gt;\r\n\r\n<\/pre>\n<h3>\/res\/layout\/row_phoneno.xml<\/h3>\n<pre class=\"prettyprint linenums\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n                 android:id=\"@+id\/LinearLayout01\" \r\n                 android:layout_width=\"fill_parent\" \r\n                 android:layout_height=\"fill_parent\"&gt;\r\n    &lt;TextView android:id=\"@+id\/lbl_id\" \r\n            android:layout_width=\"wrap_content\" \r\n            android:layout_height=\"wrap_content\" &gt;\r\n            &lt;\/TextView&gt;\r\n    &lt;TextView android:text=\" : \" \r\n            android:layout_width=\"wrap_content\" \r\n            android:layout_height=\"wrap_content\" &gt;\r\n            &lt;\/TextView&gt;\r\n    &lt;TextView android:id=\"@+id\/lbl_name\" \r\n            android:layout_width=\"wrap_content\" \r\n            android:layout_height=\"wrap_content\" &gt;\r\n            &lt;\/TextView&gt;\r\n    &lt;TextView android:text=\" : \" \r\n            android:layout_width=\"wrap_content\" \r\n            android:layout_height=\"wrap_content\" &gt;\r\n            &lt;\/TextView&gt;\r\n    &lt;TextView android:id=\"@+id\/lbl_phone\" \r\n            android:layout_width=\"wrap_content\" \r\n            android:layout_height=\"wrap_content\" &gt;\r\n            &lt;\/TextView&gt;\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p>\u3042\u3068\u3001\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u3067\u3001\u4ee5\u4e0b\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a<\/p>\n<pre class=\"prettyprint linenums\">&lt;uses-permission android:name=\"android.permission.CALL_PHONE\"&gt;&lt;\/uses-permission&gt;\r\n&lt;uses-permission android:name=\"android.permission.READ_CONTACTS\"&gt;&lt;\/uses-permission&gt;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u96fb\u8a71\u756a\u53f7\u3092\u5165\u308c\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30c0\u30a4\u30e4\u30eb\u753b\u9762\u306b\u9077\u79fb\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u3002 \u30b3\u30f3\u30bf\u30af\u30c8\u30ea\u30b9\u30c8\u304b\u3089\u3001\u30e6\u30fc\u30b6\u30fcID\u3001\u8868\u793a\u540d\u3001\u96fb\u8a71\u756a\u53f7\u3092\u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\u306b\u8868\u793a\u3057\u3001\u9078\u629e\u3055\u308c\u305f\u3089\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u96fb\u8a71\u756a\u53f7\u3092\u8a2d\u5b9a\u3059\u308b\u3002 &#038;nbs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","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-224","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\/224","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=224"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/224\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}