{"id":822,"date":"2023-03-14T20:17:37","date_gmt":"2023-03-14T11:17:37","guid":{"rendered":"https:\/\/www.dogrow.net\/android\/?p=822"},"modified":"2023-03-15T06:39:45","modified_gmt":"2023-03-14T21:39:45","slug":"blog43","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/android\/blog43\/","title":{"rendered":"(43) Android\u30a2\u30d7\u30ea\u304b\u3089\u30dc\u30bf\u30f3\u4e00\u767a\u3067\u96fb\u8a71\u3092\u304b\u3051\u308b\u3002"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u81ea\u4f5c\u30a2\u30d7\u30ea\u4e0a\u306b\u30dc\u30bf\u30f3\u3092\u8a2d\u7f6e\u3059\u308b\u3002<br \/>\n\u3053\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b\u6642\u306b\u3001\u56fa\u5b9a\u306e\u96fb\u8a71\u756a\u53f7\u306b\u767a\u4fe1\u3057\u305f\u3044\u3002<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b<\/h1>\n<h2 class=\"my_h\">1) \u5927\u5148\u751f\u306b\u304a\u77e5\u6075\u3092\u62dd\u501f<\/h2>\n<p>ChatGPT\u5927\u5148\u751f\u306b\u8cea\u554f\u3057\u305f\u7d50\u679c\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/android\/wp-content\/uploads\/2023\/03\/Image2.jpg\" alt=\"\" class=\"my_add_bs1\" \/><\/p>\n<p>\u4e0a\u8a18\u306e\u753b\u50cf\u3060\u3068\u53f3\u306e\u65b9\u304c\u898b\u5207\u308c\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u30c6\u30ad\u30b9\u30c8\u3067\u5f35\u308a\u4ed8\u3051\u308b\u3002<br \/>\n\u203b\u4e00\u90e8\u3060\u3051\u52dd\u624b\u306b\u30b3\u30fc\u30c9\u3092\u8ffd\u8a18\u3057\u305f\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nprivate static final int REQUEST_CALL = 1;\r\n\r\nprivate void makePhoneCall() {\r\n    String phoneNumber = &quot;tel:&quot; + &quot;\u3053\u3053\u306b\u96fb\u8a71\u756a\u53f7\u3092\u5165\u529b&quot;;\r\n\r\n    Intent intent = new Intent(Intent.ACTION_CALL);\r\n    intent.setData(Uri.parse(phoneNumber));\r\n\r\n    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {\r\n        \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u307e\u3059\u3002\r\n        ActivityCompat.requestPermissions(this, new String&#x5B;]{android.Manifest.permission.CALL_PHONE}, REQUEST_CALL);\r\n    } else {\r\n        \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u96fb\u8a71\u3092\u304b\u3051\u307e\u3059\u3002\r\n        try{\r\n            startActivity(intent);\r\n        }catch(SecurityException e){\r\n            Toast.makeText(getApplicationContext(), &quot;\u767a\u4fe1\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002&quot;, Toast.LENGTH_SHORT).show();\r\n        }\r\n    }\r\n}\r\n\r\n@Override\r\npublic void onRequestPermissionsResult(int requestCode, @NonNull String&#x5B;] permissions, @NonNull int&#x5B;] grantResults) {\r\n    super.onRequestPermissionsResult(requestCode, permissions, grantResults);\r\n    if (requestCode == REQUEST_CALL) {\r\n        if (grantResults.length &gt; 0 &amp;&amp; grantResults&#x5B;0] == PackageManager.PERMISSION_GRANTED) {\r\n            \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u96fb\u8a71\u3092\u304b\u3051\u307e\u3059\u3002\r\n            makePhoneCall();\r\n        } else {\r\n            Toast.makeText(getApplicationContext(), &quot;\u96fb\u8a71\u3092\u304b\u3051\u308b\u305f\u3081\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u3067\u3059\u3002&quot;, Toast.LENGTH_SHORT).show();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Permission\u306e\u8a18\u8ff0\u306b\u95a2\u3059\u308b\u8aac\u660e\u304c\u3001<br \/>\n<span class=\"my_fc_crimsonBBig\">\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u9069\u5207\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u306b\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/span><br \/>\n\u3068\u7701\u7565\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u308c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u306b <span class=\"my_fc_deeppinkB\">AndroidManifest.xml<\/span> \u306b\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot; \/&gt;\r\n<\/pre>\n<p>ChatGPT\u306f\u7d20\u6674\u3089\u3057\u3044\uff01<br \/>\n\u8cea\u554f\u306b\u5bfe\u3059\u308b\u56de\u7b54\u304c\u305a\u308c\u3066\u3044\u305f\u5834\u5408\u3067\u3082\u3001\u3053\u3061\u3089\u306e\u8cea\u554f\u6587\u3092\u5f90\u3005\u306b\u4fee\u6b63\u3057\u3066\u3044\u3051\u3070\u3001\u671f\u5f85\u3059\u308b\u56de\u7b54\u306b\u8fd1\u3065\u3044\u3066\u3044\u304f\u3002<\/p>\n<h2 class=\"my_h\">2) \u52a9\u8a00\u901a\u308a\u306b\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/h2>\n<p>\u5b9f\u969b\u306b\u52d5\u4f5c\u3057\u305f\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3002<\/p>\n<h3 class=\"my_h\">(1) AndroidManifest.xml<\/h3>\n<pre class=\"brush: xml; highlight: [4]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\r\n    xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;&gt;\r\n    &lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot; \/&gt;\r\n    &lt;application\r\n        android:allowBackup=&quot;true&quot;\r\n        android:dataExtractionRules=&quot;@xml\/data_extraction_rules&quot;\r\n        android:fullBackupContent=&quot;@xml\/backup_rules&quot;\r\n        android:icon=&quot;@mipmap\/ic_launcher&quot;\r\n        android:label=&quot;@string\/app_name&quot;\r\n        android:roundIcon=&quot;@mipmap\/ic_launcher_round&quot;\r\n        android:supportsRtl=&quot;true&quot;\r\n        android:theme=&quot;@style\/Theme.TestPhoneCall&quot;\r\n        tools:targetApi=&quot;31&quot;&gt;\r\n        &lt;activity\r\n            android:name=&quot;.MainActivity&quot;\r\n            android:exported=&quot;true&quot;&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=&quot;android.intent.action.MAIN&quot; \/&gt;\r\n\r\n                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n            &lt;meta-data\r\n                android:name=&quot;android.app.lib_name&quot;\r\n                android:value=&quot;&quot; \/&gt;\r\n        &lt;\/activity&gt;\r\n    &lt;\/application&gt;\r\n&lt;\/manifest&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(2) MainActivity.java<\/h3>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.example.testphonecall;\r\n\r\nimport androidx.annotation.NonNull;\r\nimport androidx.appcompat.app.AppCompatActivity;\r\nimport androidx.core.app.ActivityCompat;\r\n\r\nimport android.content.Intent;\r\nimport android.content.pm.PackageManager;\r\nimport android.net.Uri;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n    private static final int REQUEST_CALL = 1;\r\n    private final Intent intentPhone = new Intent(Intent.ACTION_CALL);\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n    }\r\n\r\n    public void OnPushCallTaro(View view){\r\n        makePhoneCall();\r\n    }\r\n\r\n    private void makePhoneCall() {\r\n        String phoneNumber = &quot;tel:xxxxxxxxxxxx&quot;;   \/\/ \u2605\u96fb\u8a71\u756a\u53f7\u3092\u66f8\u304f\u3002\r\n        intentPhone.setData(Uri.parse(phoneNumber));\r\n\r\n        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {\r\n            \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u307e\u3059\u3002\r\n            ActivityCompat.requestPermissions(this, new String&#x5B;]{android.Manifest.permission.CALL_PHONE}, REQUEST_CALL);\r\n        } else {\r\n            \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u96fb\u8a71\u3092\u304b\u3051\u307e\u3059\u3002\r\n            try{\r\n                startActivity(intentPhone);\r\n            }catch(SecurityException e){\r\n                Toast.makeText(getApplicationContext(), &quot;\u767a\u4fe1\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002&quot;, Toast.LENGTH_SHORT).show();\r\n            }\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onRequestPermissionsResult(int requestCode, @NonNull String&#x5B;] permissions, @NonNull int&#x5B;] grantResults) {\r\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults);\r\n        if (requestCode == REQUEST_CALL) {\r\n            if (grantResults.length &gt; 0 &amp;&amp; grantResults&#x5B;0] == PackageManager.PERMISSION_GRANTED) {\r\n                \/\/ \u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u8a31\u53ef\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u96fb\u8a71\u3092\u304b\u3051\u307e\u3059\u3002\r\n                makePhoneCall();\r\n            } else {\r\n                Toast.makeText(getApplicationContext(), &quot;\u96fb\u8a71\u3092\u304b\u3051\u308b\u305f\u3081\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u3067\u3059\u3002&quot;, Toast.LENGTH_SHORT).show();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 \u81ea\u4f5c\u30a2\u30d7\u30ea\u4e0a\u306b\u30dc\u30bf\u30f3\u3092\u8a2d\u7f6e\u3059\u308b\u3002 \u3053\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b\u6642\u306b\u3001\u56fa\u5b9a\u306e\u96fb\u8a71\u756a\u53f7\u306b\u767a\u4fe1\u3057\u305f\u3044\u3002 2. \u3084\u3063\u3066\u307f\u308b 1) \u5927\u5148\u751f\u306b\u304a\u77e5\u6075\u3092\u62dd\u501f ChatGPT\u5927\u5148\u751f\u306b\u8cea\u554f\u3057\u305f\u7d50\u679c\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3002 \u4e0a\u8a18\u306e\u753b\u50cf\u3060\u3068\u53f3\u306e\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/android\/blog43\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-822","post","type-post","status-publish","format-standard","hentry","category-androidstudio"],"views":837,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/comments?post=822"}],"version-history":[{"count":15,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/822\/revisions"}],"predecessor-version":[{"id":852,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/822\/revisions\/852"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/media?parent=822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/categories?post=822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/tags?post=822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}