【Programming】Android Development vol.5 / Androidアプリの実行

in #promari6 years ago

前回はAVD(Android Virtual Device)と呼ばれるエミュレータの作成と初期設定の手順をご紹介致しました。今回はAndroidアプリケーションの実行方法をご紹介致します。

<p dir="auto"><a href="https://ja.wikipedia.org/wiki/Android_Studio" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Android Studioのツールバーの「▶」ボタンをクリックします。「Run」メニューから「Run 'app'」を選択してもかまいません。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/pkdqlbcay3.png" alt="pkdqlbcay3.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/pkdqlbcay3.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/pkdqlbcay3.png 2x" /> <p dir="auto">実行するデバイスを選択します。起動中のAVD(Nexus 5X API 28)を選択し、「OK」ボタンをクリックします。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/mjoiokuz41.png" alt="mjoiokuz41.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/mjoiokuz41.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/mjoiokuz41.png 2x" /> <p dir="auto">アプリのビルドが終わるまで待機します。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/i6xkplwmpl.png" alt="i6xkplwmpl.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/i6xkplwmpl.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/i6xkplwmpl.png 2x" /> <p dir="auto">ビルドが終わると、AVD上でアプリが実行されます。AVDエミュレータ上で「Hello World!」と表示されましたら、はじめてのAndroidアプリの実行に成功したことになります。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/dcfh6uj8fa.png" alt="dcfh6uj8fa.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/dcfh6uj8fa.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/dcfh6uj8fa.png 2x" /> <p dir="auto">この「Hello World!」という文字列はres/layoutフォルダのactivity_main.xmlに記載されたテキストが表示されます。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/ov390oxg2k.png" alt="ov390oxg2k.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/ov390oxg2k.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/ov390oxg2k.png 2x" /> <p dir="auto">activity_main.xmlの内容を見てみましょう。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/rjqcyh22eu.png" alt="rjqcyh22eu.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/rjqcyh22eu.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/rjqcyh22eu.png 2x" /> <p dir="auto">AttributeタブのTextViewのtextに「Hello World!」が入力されています。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/0n6uo31hss.png" alt="0n6uo31hss.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/0n6uo31hss.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/0n6uo31hss.png 2x" /> <p dir="auto">任意の文字列に変更してみましょう。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/elkirfm7uc.png" alt="elkirfm7uc.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/elkirfm7uc.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/elkirfm7uc.png 2x" /> <p dir="auto">変更しましたら「▶」ボタンを実行しAVDを起動します。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/nax9r5nefk.png" alt="nax9r5nefk.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/nax9r5nefk.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/nax9r5nefk.png 2x" /> <p dir="auto">「Hello World!」とう文字列が変更されました。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/kf6sboqj1m.png" alt="kf6sboqj1m.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/kf6sboqj1m.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/kf6sboqj1m.png 2x" /> <p dir="auto">「Promari Steem Application」という文字列が表示されています。こちらはアプリケーションの名前です。アンドロイドプロジェクトを作成するときに、入力したプロジェクト名が表示されます。 <p dir="auto">プロジェクトのres/valuesフォルダのstyles.xmlに入力したプロジェクト名が記載されています。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/ccq9kk2z7p.png" alt="ccq9kk2z7p.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/ccq9kk2z7p.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/ccq9kk2z7p.png 2x" /> <p dir="auto">styles.xmlの内容を見てみましょう。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/uhfe0i6ml1.png" alt="uhfe0i6ml1.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/uhfe0i6ml1.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/uhfe0i6ml1.png 2x" /> <p dir="auto"><code>Promari Steem Applicationと記載されています。この文字列がエミュレータ上のNexus 5Xに表示されたわけです。 <p dir="auto">任意の文字列に編集してみましょう。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/vh6nt7365d.png" alt="vh6nt7365d.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/vh6nt7365d.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/vh6nt7365d.png 2x" /> <p dir="auto">「▶」ボタンを実行しAVDを起動します。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/nax9r5nefk.png" alt="nax9r5nefk.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/nax9r5nefk.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/nax9r5nefk.png 2x" /> <p dir="auto">「Promari Steem Application」という文字列が変更されました。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/zba3vzb2ii.png" alt="zba3vzb2ii.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/zba3vzb2ii.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/zba3vzb2ii.png 2x" /> <p dir="auto">如何でしょうか。Androidの開発では統合開発環境(IDE)であるAndroid Studioを用いて仮想端末の動作検証や仮想端末に必要な開発環境のプロジェクトの作成等を手軽に実装することができます。 <p dir="auto">皆様も是非、Androidライフを楽しんでみては如何でしょうか。 <p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://img.esteem.ws/t0r78hqbeu.png" alt="t0r78hqbeu.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/t0r78hqbeu.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/t0r78hqbeu.png 2x" /><br /> <br /> written by <a href="https://steemit.com/@tamito0201/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">tamito0201 <p dir="auto">プログラミングとのご縁結びなら<a href="https://www.programming-mariage.jp/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">プロマリへ。 <p dir="auto">オンラインプログラミング学習スクールの<a href="https://www.programming-mariage.jp/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">プロマリは、プログラミングの初学者の皆様を応援しています。プログラミング講師と一緒に面白いアプリを作りませんか。 <p dir="auto"><a href="https://www.programming-mariage.jp" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/btpb5hmlur.png" alt="btpb5hmlur.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/btpb5hmlur.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/btpb5hmlur.png 2x" /> <p dir="auto">The programming school "<a href="https://www.programming-mariage.jp/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Promari" will help you learn programming. "<a href="https://www.programming-mariage.jp/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Promari" is supporting the first scholars of programming. Let's develop an application with our programming instructor.
Sort:  

Thanks for using eSteem!
Your post has been voted as a part of eSteem encouragement program. Keep up the good work! Install Android, iOS Mobile app or Windows, Mac, Linux Surfer app, if you haven't already!

Learn more: https://esteem.app Join our discord: https://discord.gg/8eHupPq

Congratulations @promari! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><span><img src="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201903071230" srcset="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201903071230 1x, https://images.hive.blog/1536x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201903071230 2x" /><td>You received more than 7000 upvotes. Your next target is to reach 8000 upvotes. <p dir="auto"><sub><em><a href="https://steemitboard.com/@promari" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Click here to view your Board<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <h6><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for @Steemitboard as a witness and get one more award and increased upvotes!