*>What am I doing wrong?*
Not meaning to be rude here, but pretty much everything... ;-)  You should
never create a new instance of an activity.  That is handled by the Android
OS.

You probably want to use the Intent constructor that takes a Context and a
Class object... that is what I always do when calling activities that are
part of my applications.

Assuming onClick() is defined in your activity, your code would look
something like this:

My onClick() looks like this
{
        Intent myIntent = new Intent(this, MultipleActivity.class);
        this.startActivity(myIntent);
}

If your onClick() is defined inside your activity then the this pointer is
your Context object, so that is what you pass in to the Intent constructor
and that is what you use to call startActivity.

Hope that helps,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Tue, May 11, 2010 at 2:55 PM, Ubuntu Explorer
<[email protected]>wrote:

> Hi,
>
> I am trying to write a simple multiple activity application - each of which
> has a xml layout file (containing a button)
> On the button click, the need to switch between the activities.
>
> My onClick() looks like this
>
> {
>         Intent myIntent = new Intent("Multi2");
>         Activity act2 = new MultipleActivity();
>         act2.startActivity(myIntent);
> }
>
> And I have exact replica of code in my second activity as well.
>
> However, when I click on my button, it freezes. Sometimes, there is a force
> close warning.
>
> What am I doing wrong?
>
> Regards,
> UE.
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to