Switching Activities in Android Studio: Android Programming
HTML-код
- Опубликовано: 27 ноя 2024
- Create and launch a second Android activity. Covers Intent, startActivity(), finish(), and the activity stack.
For tutorial on creating a button, see • Creating a Button: And...
Initial setup:
--------------------
Have project with initial activity and button for Toast
Create new activity: SecondActivity
--------------------
Show .xml, .java, and manifest.
Launch activity:
--------------------
startActivity(new Intent( [Current Activity's 'this'], [New Activity's Java].class));
Encapsulate launching
--------------------
Intent i = SecondClass.makeIntent(this)
startActivity();
Activity Stack
--------------------
Loading an Activity pushes it on the Activity Stack
Pressing back button pops stack:
destroys this activity, returns to previous activity.
New Button runs activity's finish() method pops it in code.
Must use correctly to have good activity stack.
If you instead startActivity() back to the first one, you make a loop.
Can move on and kill current activity:
--------------------
startActivity(...);
finish();
Troubleshooting:
--------------------
Demonstrate what happens with the activity being in the manifest.
View LogCat via DDMS:
...android.content.ActivityNotFoundException: Unable to find explicit activity class ...; have you declared this activity in your AndroidManifest.xml?
Given how fragmented Android's versions are against each other, it's so relieving to have these concise video that just get to the point straight away. Can't thank you enough for providing these tutorials!
This is very well done, it's a simple process but you explain it in a manner that anyone can understand. Thank you Doctor.
Thank you so much sir
I will always face this problem during android development
But I am unable to fix the bug
But after watching this video I will done this
Thank you for the fine explanations and demo, mister !
Very helpful video! Thanks!
your tutorial is so much better
hi Brian, what'ss the diference between "finish()" a SecondActivity and using "android:parentActivityName" in Manifest. My problem is that I have a filter in MainActivity and when i get back from SecondActivity I lost that filter.
hello, i am seeing only two activities blank and other , i want to see more activities like login, maps and others please help me
Great video
Thx brooo ^^ You healp me to resolve that prob
Somewhere at 8:00+ lost it completely. As I understand that's due to lack of experience, although I am a moderate programmer, but such things bug me out always. You can't see any logic of what's going on completely, basically just remember it and roll with it, that's how it works.
Software link to download sir
it is not goog video
your spelling too, not good
Suresh Mca Thats true, Its not a good video IT IS A GREAT VIDEO!
@Suresh Mca, it always helps to be precise or clear when you express a negative opinion about anything in life.
What do you mean by "not good"? Is it the contents of the tutorial or the quality of the video used to present the tutorial? Any suggestions as to how to make it "good" according to your standards?