It looks like you got your problem sorted out, but I thought I'd point
out another solution that avoids the behavior Mark described with the
back button relaunching SecondActivity: using AliasActivity for Test.

http://developer.android.com/reference/android/app/AliasActivity.html

and check out <sdkdir>/src/frameworks/base/core/java/android/app/
AliasActivity.java

>From the javadoc:
 * Stub activity that launches another activity (and then finishes
itself)
 * based on information in its component's manifest meta-data.  This
is a
 * simple way to implement an alias-like mechanism.

The notable difference being that all the configuration happens in XML
as opposed to in Java. (Using your current approach you can probably
just add a finish() in your Test.onResume())

-Andrew

On Sep 4, 9:05 pm, BJP <[email protected]> wrote:
> Aha, you are indeed correct about registration in the manifest.
>
> Is there a reason Google wouldn't want to automatically register any
> class inheriting Activity in the manifest as an Activity?
>
> As I wrote in my original message, the Activity equivalent to Test
> will eventually have GUI elements (a Button, for example) whose events
> will trigger SecondActivity; for now, I want to skip that and just
> develop SecondActivity.  So the behavior you describe is exactly what
> I'm after (for now).
>
> Thanks again!
> --Ben
>
> On Sep 4, 5:52 pm, "Mark Murphy" <[email protected]> wrote:
>
> > > I have a skeleton system of Activities that will eventually be filled
> > > with GUI elements, but for now I just want to work on a particular
> > > aspect of the project without developing the initial GUI parts first.
> > > But, when I try to launch an Intent from onResume, I get a
> > > RuntimeException in ActivityThread.performResumeActivity.  What is
> > > wrong with the following code?
>
> > > public class Test extends Activity {
> > >     @Override
> > >     public void onCreate(Bundle savedInstanceState) {
> > >         super.onCreate(savedInstanceState);
> > >         setContentView(R.layout.main);
> > >     }
>
> > >     public void onResume() {
> > >            Intent i = new Intent(this, SecondActivity.class);
> > >            this.startActivity(i);
> > >     }
>
> > >     public class SecondActivity extends Activity {
> > >         @Override
> > >         public void onCreate(Bundle savedInstanceState) {
> > >             super.onCreate(savedInstanceState);
> > >             setContentView(R.layout.main);
> > >         }
> > >     }
> > > }
>
> > What you are doing makes no sense.
>
> > When the Test activity starts up, onResume() is called. At that point, you
> > start SecondActivity, so the user is presented with SecondActivity right
> > away. The user back-buttons out of SecondActivity, at which point
> > onResume() on Test gets called...starting up SecondActivity again.
>
> > Do not call startActivity() in onResume(). Do it based on user input
> > (menu, button, list item click, etc.).
>
> > Beyond that, look at your stack trace to find out the source of your
> > exception (use adb logcat, DDMS, or the DDMS perspective in Eclipse to get
> > the Java stack trace). Perhaps SecondActivity is not registered in your
> > AndroidManifest.xml file?
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > Android App Developer Books:http://commonsware.com/books.html
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to