Summary of "안드로이드 앱 만들기 #3 (Intent 화면전환) - 쉽게 앱 만드는 방법 (현직 개발자 설명) , android studio easy tutorial"
Main focus / concepts covered
This tutorial demonstrates how to navigate between Activities (screens) in an Android app using Intents and how to pass data between them.
Key concepts:
- What an Intent is: the mechanism to navigate between Activities.
- Creating a second Activity (SubActivity) and its layout XML so you can move from Activity A → Activity B.
- Wiring UI elements in XML (Button, EditText, TextView), assigning IDs, and connecting them in Java with
findViewById. - Handling clicks with
OnClickListenerto trigger navigation. - Creating and using an Intent:
new Intent(CurrentActivity.this, SubActivity.class)startActivity(intent)
- Passing data between Activities:
- Put data into the Intent before starting:
intent.putExtra("key", value)(e.g., a String from anEditText). - Receive data in the destination Activity:
getIntent().getStringExtra("key")(or othergetXExtravariants) and set it into aTextView.
- Put data into the Intent before starting:
- Common Android details and gotchas:
- Always end Java statements with semicolons.
- Use Alt+Enter or auto-complete to add imports if needed.
- Lifecycle/timing bug: do not capture
EditTexttext at app startup if you want the user’s later input — read theEditTextand callputExtrainside the button’s click handler so current input is sent. - If sending numeric types, convert appropriately (e.g.,
putExtra/getIntExtra).
Running and testing:
- Build and run on a physical Android device or an emulator to verify navigation and data passing.
- This pattern (
Intent+putExtra/getIntent) is widely used and practical in real apps.
Step-by-step guide (high-level)
- Create a project and add a new Activity (e.g.,
SubActivity) via New → Activity. - Edit layout XMLs:
- Use a
LinearLayout. - Add an
EditTextfor input, aButton(Move), and aTextViewto show received text.
- Use a
-
In
MainActivity.java:-
Declare and initialize UI references:
java EditText editText = findViewById(R.id.xxx); Button btnMove = findViewById(R.id.xxx); -
In
btnMove.setOnClickListener:java btnMove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String text = editText.getText().toString(); Intent i = new Intent(MainActivity.this, SubActivity.class); i.putExtra("sdr", text); startActivity(i); } });
-
-
In
SubActivity.java:java TextView tvSub = findViewById(R.id.tv_sub); String s = getIntent().getStringExtra("sdr"); tvSub.setText(s); -
Fix lifecycle issues by ensuring data is fetched and put into the Intent at the moment the user clicks the button (not at app startup).
Tip: always call editText.getText().toString() inside the click handler so you send the current input.
Troubleshooting tips
- If text isn’t passed, check that you call
editText.getText().toString()inside the click handler before creating/starting the Intent. - Verify IDs in XML match those used in
findViewById(). - Use auto-import (Alt+Enter) for missing imports.
- Watch the logcat and run on an emulator/device to confirm behavior.
Lifecycle/timing bug: do not capture
EditTexttext at startup; read it and callputExtrainside the button’s click handler so the user’s current input is sent.
Additional notes
- Instructor briefly mentions UI tweaks (text size using
sp), layout choices (e.g.,LinearLayout), and project/theme settings. - There is an offline chat/Q&A available (per instructor) for follow-up questions.
Main speaker / source
- Hoeung Druid (현직 개발자)
Category
Technology
Share this summary
Is the summary off?
If you think the summary is inaccurate, you can reprocess it with the latest model.