{"id":37183,"date":"2024-11-01T09:55:34","date_gmt":"2024-11-01T09:55:34","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37183"},"modified":"2024-11-01T11:36:19","modified_gmt":"2024-11-01T11:36:19","slug":"java-android-app-development-course-activity-control","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37183\/","title":{"rendered":"Java Android App Development Course, Activity Control"},"content":{"rendered":"<p><body><\/p>\n<p>\n        In the Android platform, <strong>Activity<\/strong> is a key component that constitutes the user interface.<br \/>\n        An activity can be viewed as a screen where the user can perform specific tasks and represents the basic building block of an Android application.\n    <\/p>\n<h2>What is an Activity?<\/h2>\n<p>\n        An activity is a screen that displays a specific task to the user. For example, screens where users can click buttons or<br \/>\n        input information are all considered activities. Each activity exists independently and allows users<br \/>\n        to perform various tasks by switching between multiple activities.\n    <\/p>\n<h2>Activity Lifecycle<\/h2>\n<p>\n        An activity has states such as creation, start, pause, resume, stop, and destruction, and these states are managed through<br \/>\n        the activity&#8217;s lifecycle. Understanding the activity lifecycle is crucial for app development.\n    <\/p>\n<h3>Lifecycle Methods<\/h3>\n<ul>\n<li><code>onCreate()<\/code>: Called when the activity is first created. Initializes UI and performs setup tasks.<\/li>\n<li><code>onStart()<\/code>: Called when the activity is about to become visible to the user.<\/li>\n<li><code>onResume()<\/code>: Called when the activity starts interacting with the user.<\/li>\n<li><code>onPause()<\/code>: Called when another activity is about to start interacting with the user. Used to save important tasks.<\/li>\n<li><code>onStop()<\/code>: Called when the activity is no longer visible to the user.<\/li>\n<li><code>onDestroy()<\/code>: Called when the activity is finishing. Used to clean up remaining resources to prevent memory leaks.<\/li>\n<\/ul>\n<h2>Activity Example<\/h2>\n<p>\n        Below is a sample code that creates a basic activity and implements lifecycle methods.<br \/>\n        In this example, the current state will be displayed in a TextView.\n    <\/p>\n<pre><code>\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onCreate called\");\n    }\n\n    @Override\n    protected void onStart() {\n        super.onStart();\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onStart called\");\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onResume called\");\n    }\n\n    @Override\n    protected void onPause() {\n        super.onPause();\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onPause called\");\n    }\n\n    @Override\n    protected void onStop() {\n        super.onStop();\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onStop called\");\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"onDestroy called\");\n    }\n}\n    <\/code><\/pre>\n<h2>Communication Between Intents and Activities<\/h2>\n<p>\n        In Android, transitions between activities occur through <strong>Intents<\/strong>.<br \/>\n        An intent is an object used to pass information from one activity to another or to call system components.\n    <\/p>\n<h3>Intent Usage Example<\/h3>\n<p>\n        Let\u2019s look at sample code that creates two activities, where clicking a button in the first activity<br \/>\n        transitions to the second activity.\n    <\/p>\n<pre><code>\n\/\/ MainActivity.java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        Button button = findViewById(R.id.button);\n        button.setOnClickListener(v -&gt; {\n            Intent intent = new Intent(MainActivity.this, SecondActivity.class);\n            startActivity(intent);\n        });\n    }\n}\n\n\/\/ SecondActivity.java\npublic class SecondActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_second);\n        TextView textView = findViewById(R.id.textView);\n        textView.setText(\"This is the second activity.\");\n    }\n}\n    <\/code><\/pre>\n<h2>Passing Data<\/h2>\n<p>\n        When using intents, you can also pass data along. Let\u2019s examine how to pass data via intents through<br \/>\n        the following example.\n    <\/p>\n<pre><code>\n\/\/ MainActivity.java (Adding data transfer)\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        Button button = findViewById(R.id.button);\n        button.setOnClickListener(v -&gt; {\n            Intent intent = new Intent(MainActivity.this, SecondActivity.class);\n            intent.putExtra(\"message\", \"Hello, Second Activity\");\n            startActivity(intent);\n        });\n    }\n}\n\n\/\/ SecondActivity.java (Receiving data)\npublic class SecondActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_second);\n        TextView textView = findViewById(R.id.textView);\n        String message = getIntent().getStringExtra(\"message\");\n        textView.setText(message);\n    }\n}\n    <\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>\n        Today we learned about activities and their lifecycle in Android app development,<br \/>\n        transitions between activities via intents, and how to pass data.<br \/>\n        These concepts are fundamental to Android app development and will serve as a starting point<br \/>\n        for creating more complex apps.<br \/>\n        In future lessons, we will cover more features and UI elements, so please stay tuned.\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the Android platform, Activity is a key component that constitutes the user interface. An activity can be viewed as a screen where the user can perform specific tasks and represents the basic building block of an Android application. What is an Activity? An activity is a screen that displays a specific task to the &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37183\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Java Android App Development Course, Activity Control&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[137],"tags":[],"class_list":["post-37183","post","type-post","status-publish","format-standard","hentry","category-java-android-app-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37183\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"In the Android platform, Activity is a key component that constitutes the user interface. An activity can be viewed as a screen where the user can perform specific tasks and represents the basic building block of an Android application. What is an Activity? An activity is a screen that displays a specific task to the &hellip; \ub354 \ubcf4\uae30 &quot;Java Android App Development Course, Activity Control&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37183\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:55:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:36:19+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Java Android App Development Course, Activity Control\",\"datePublished\":\"2024-11-01T09:55:34+00:00\",\"dateModified\":\"2024-11-01T11:36:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/\"},\"wordCount\":376,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Java Android app development\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37183\/\",\"name\":\"Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:55:34+00:00\",\"dateModified\":\"2024-11-01T11:36:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37183\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37183\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Android App Development Course, Activity Control\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37183\/","og_locale":"ko_KR","og_type":"article","og_title":"Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"In the Android platform, Activity is a key component that constitutes the user interface. An activity can be viewed as a screen where the user can perform specific tasks and represents the basic building block of an Android application. What is an Activity? An activity is a screen that displays a specific task to the &hellip; \ub354 \ubcf4\uae30 \"Java Android App Development Course, Activity Control\"","og_url":"https:\/\/atmokpo.com\/w\/37183\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:55:34+00:00","article_modified_time":"2024-11-01T11:36:19+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37183\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37183\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Java Android App Development Course, Activity Control","datePublished":"2024-11-01T09:55:34+00:00","dateModified":"2024-11-01T11:36:19+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37183\/"},"wordCount":376,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Java Android app development"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37183\/","url":"https:\/\/atmokpo.com\/w\/37183\/","name":"Java Android App Development Course, Activity Control - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:55:34+00:00","dateModified":"2024-11-01T11:36:19+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37183\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37183\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37183\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Java Android App Development Course, Activity Control"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37183"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37183\/revisions"}],"predecessor-version":[{"id":37184,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37183\/revisions\/37184"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}