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?

Комментарии • 17

  • @bryanjordan1263
    @bryanjordan1263 7 лет назад

    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!

  • @VicMonado
    @VicMonado 6 лет назад

    This is very well done, it's a simple process but you explain it in a manner that anyone can understand. Thank you Doctor.

  • @ruturajsutar9394
    @ruturajsutar9394 4 года назад +1

    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

  • @RobertMunteanu105
    @RobertMunteanu105 4 года назад

    Thank you for the fine explanations and demo, mister !

  • @boatygatling4782
    @boatygatling4782 7 лет назад +3

    Very helpful video! Thanks!

  • @wepranaga
    @wepranaga 6 лет назад

    your tutorial is so much better

  • @fliamachado
    @fliamachado 5 лет назад

    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.

  • @adarshsonare9049
    @adarshsonare9049 7 лет назад +1

    hello, i am seeing only two activities blank and other , i want to see more activities like login, maps and others please help me

  • @drunkscotsman2976
    @drunkscotsman2976 6 лет назад

    Great video

  • @hamzadaiz9002
    @hamzadaiz9002 5 лет назад

    Thx brooo ^^ You healp me to resolve that prob

  • @Jab_hutt
    @Jab_hutt 5 лет назад

    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.

  • @sulthana3585
    @sulthana3585 3 года назад

    Software link to download sir

  • @sureshmca3743
    @sureshmca3743 7 лет назад

    it is not goog video

    • @joredawal2297
      @joredawal2297 7 лет назад +1

      your spelling too, not good

    • @TitoMitto
      @TitoMitto 7 лет назад +1

      Suresh Mca Thats true, Its not a good video IT IS A GREAT VIDEO!

    • @stationHQ
      @stationHQ 7 лет назад +1

      @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?