{"id":878,"date":"2018-12-26T06:08:30","date_gmt":"2018-12-25T23:08:30","guid":{"rendered":"https:\/\/luckytruedev.com\/learning\/?p=878"},"modified":"2019-09-21T22:08:28","modified_gmt":"2019-09-21T15:08:28","slug":"pengenalan-android-intent","status":"publish","type":"post","link":"https:\/\/luckytruedev.com\/learning\/pengenalan-android-intent\/","title":{"rendered":"Pengenalan Android Intent"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4.png\" alt=\"\" class=\"wp-image-896\" width=\"518\" height=\"335\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4.png 769w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-300x194.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-768x497.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-110x71.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-420x272.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-664x430.png 664w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/xstartactivityviaintent10.png.pagespeed.ic_.v0RQxCGOt4-20x13.png 20w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><figcaption>Android Intent (Sumber Gambar Google Images)<\/figcaption><\/figure><\/div>\n\n\n\n<p>Intents memungkinkan Anda untuk berinteraksi dengan komponen dari aplikasi yang sama serta dengan komponen yang disumbangkan oleh aplikasi lain.<\/p>\n\n\n<div id=\"lucky-4291199032\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<p><br><br><strong>Sebagai Contoh, <\/strong>sebuah kegiatan dapat memulai aktivitas eksternal untuk memotret Gambar.<br><br>Sebuah Intent bisa berisi data melalui Bundle. Data ini bisa digunakan oleh komponen penerima.<br><br><strong>Sebagai Contoh: <\/strong>Intent memudahkan Anda untuk mengalihkan aktivitas Anda ke aktivitas lain pada kejadian apapun. Dengan menyebut, <strong>startActivity() <\/strong>Anda bisa melakukan tugas ini.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\">Intent intent = new\nIntent(getApplicationContext(), SecondActivity.class);\n\nstartActivity(intent);<\/pre>\n\n\n\n<p>Dalam contoh di atas, aktivitas latar depan semakin diarahkan ke aktivitas lain SecondActivity.java.getApplicationContext()<br><br>mengembalikan konteks untuk aktivitas latar depan Anda.<\/p>\n\n\n<div id=\"lucky-779261370\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"3760179245\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Tipe Intent<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11.png\" alt=\"\" class=\"wp-image-897\" width=\"348\" height=\"139\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11.png 807w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-300x120.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-768x307.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-110x44.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-420x168.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-770x308.png 770w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-11-20x8.png 20w\" sizes=\"auto, (max-width: 348px) 100vw, 348px\" \/><figcaption>Tipe pada Intent<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>1.Explisit : <\/strong><br><br>Tujuan eksplisit digunakan untuk menghubungkan aplikasi secara internal.Secara eksplisit kami menggunakan nama komponen yang akan terpengaruh oleh maksud.<br><br><strong>Sebagai Contoh: <\/strong><br>Jika kita mengenal nama kelas maka kita bisa menavigasi aplikasi dari OneActivity ke aktivitas lain menggunakan Intent.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\">Intent intent = new Intent(getApplicationContext(), SecondActivity.class);\nstartActivity(intent);<\/pre>\n\n\n\n<p><strong>2. Implisit&nbsp;:<\/strong><br><br>Dengan maksud tersirat, kami perlu menentukan nama komponen Kami hanya menentukan Tindakan yang harus dilakukan dan selanjutnya tindakan ini ditangani oleh komponen aplikasi lain.<br><br>Contoh <strong>dasar <\/strong>Maksud implisit adalah membuka halaman web apapun<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\">Intent intentObj = new Intent(Intent.ACTION_VIEW);\nintentObj.setData(Uri.parse(\"http:\/\/www.AndroidSquad.Net\"));\nstartActivity(intentObj);<\/pre>\n\n\n<div id=\"lucky-1721335619\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"3760179245\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Contoh Intent<\/strong><\/h2>\n\n\n\n<p>Langkah ke-1: Mari Membuat Desain UI pada activity_main.xml Rancang dua tombol Intent Eksplisit dan Niat Terimplikasi.<br><br>Langkah ke-2: Membuat Aktifitas baru yang bernama: \u201dActivity Kedua&#8221;.<br><br>Langkah ke-3: Tulis kode ini dalam MainActivity.java.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\">public class MainActivity extends AppCompatActivity {\n\n    Button explicit_btn, implicit_btn;\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        explicit_btn = (Button)findViewById(R.id.explicit_Intent);\n        implicit_btn = (Button) findViewById(R.id.implicit_Intent);\n\n        explicit_btn.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                Intent intent = new  Intent(getBaseContext(), SecondActivity.class);\n                startActivity(intent);\n            }\n        });\n        implicit_btn.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n\n                Intent intent = new Intent(Intent.ACTION_VIEW);\n                intent.setData(Uri.parse(\u201cwww.youtube.com\/AndroidMasterApp\"));\n                startActivity(intent);\n            }\n        });    }}<\/pre>\n\n\n<div id=\"lucky-3430689664\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Contoh Intent Eksplisit<\/strong><\/h2>\n\n\n\n<p>1- Mendesain Antarmuka Pengguna, Buat 2 Activity &amp; Buat teks seperti ini.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"649\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-1024x649.png\" alt=\"\" class=\"wp-image-898\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12.png 1024w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-300x190.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-768x487.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-110x70.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-420x266.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-678x430.png 678w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture1-12-20x13.png 20w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Langkah Pertama<\/figcaption><\/figure><\/div>\n\n\n\n<p>2- Dalam Activity Kedua, Buat 2 Teks dengan rating Bar.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"649\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-1024x649.png\" alt=\"\" class=\"wp-image-899\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5.png 1024w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-300x190.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-768x487.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-110x70.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-420x266.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-678x430.png 678w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture2-5-20x13.png 20w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Langkah Kedua<\/figcaption><\/figure><\/div>\n\n\n\n<p>3- Koding <strong>PutExtra(): <\/strong>Ini akan mentransfer nilai antar activity <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-1024x654.png\" alt=\"\" class=\"wp-image-900\" width=\"538\" height=\"343\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4.png 1024w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-300x192.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-768x491.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-110x70.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-420x268.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-673x430.png 673w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture3-4-20x13.png 20w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><figcaption>Langkah Ketiga<\/figcaption><\/figure><\/div>\n\n\n\n<p>4- Menerima Data Dari Activity Pertama :<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"676\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-1024x676.png\" alt=\"\" class=\"wp-image-901\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2.png 1024w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-300x198.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-768x507.png 768w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-110x73.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-420x277.png 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-651x430.png 651w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2018\/12\/Picture4-2-20x13.png 20w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Langkah Keempat<br><\/figcaption><\/figure><\/div>\n\n\n\n<p>Sumber : Master Android (App)<\/p>\n<div id=\"lucky-1654091312\" class=\"lucky-after-content lucky-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Intents memungkinkan Anda untuk berinteraksi dengan komponen dari aplikasi yang sama serta dengan komponen yang disumbangkan oleh aplikasi lain. Sebagai Contoh, sebuah kegiatan dapat memulai aktivitas eksternal untuk memotret Gambar. Sebuah Intent bisa berisi data melalui Bundle. Data ini bisa digunakan oleh komponen penerima. Sebagai Contoh: Intent memudahkan Anda untuk mengalihkan aktivitas Anda ke aktivitas [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":896,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ltdv-android-tutor"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":1,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":2278,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/878\/revisions\/2278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/media\/896"}],"wp:attachment":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}