How to start a new form?

10 views
Skip to first unread message

Chen Chen

unread,
Feb 10, 2012, 7:58:44 PM2/10/12
to android-progr...@googlegroups.com
Hi,

How to start a new form?

I tried to use  startNewForm("TopScoreActivity.class", String.valueOf(score)); 

and

 startNewForm("TopScoreActivity", String.valueOf(score)); 

both got "can not find the screen.

thanks

Chen

M. Hossein Amerkashi

unread,
Feb 10, 2012, 10:31:09 PM2/10/12
to android-progr...@googlegroups.com
Chen,

A form is basically a subclass of Activity.

So, from one activity (form) to start another, use the following:

startActivity(new Intent(this, MyOtherActivity.class));        //this would be your other activity / bridge form that you want to start
finishActivity();                                                              //drop the the current activity from memory

-Hossein

Chen Chen

unread,
Feb 10, 2012, 10:38:45 PM2/10/12
to android-progr...@googlegroups.com
Thanks a lot, seems still need to use the google's api instead of ours. 

Chen

M. Hossein Amerkashi

unread,
Feb 10, 2012, 11:03:18 PM2/10/12
to android-progr...@googlegroups.com
Okay, I see what you are doing and it should've worked. Is your TopScoreActivity in the same package as the one that's trying to initiate the new activity?

startNewForm("TopScoreActivity.class", String.valueOf(score));


-Hossein.

Chen Chen

unread,
Feb 10, 2012, 11:05:37 PM2/10/12
to android-progr...@googlegroups.com
Yes, they are in the same package. But the previous one just can't find it. Maybe I just input the name with a wrong way.

M. Hossein Amerkashi

unread,
Feb 10, 2012, 11:43:41 PM2/10/12
to android-progr...@googlegroups.com
Chen,

I just tried, and it worked fine for me. My activities are in the same package and make sure that you have the activity defined in manifiest

startNewForm("RingerActivity", "nothing");

manifiest:
        <activity android:name=".RingerActivity" android:label="@string/app_name"/>

Chen Chen

unread,
Feb 10, 2012, 11:46:08 PM2/10/12
to android-progr...@googlegroups.com
You are right, I forgot the manifiest. Now it works. 

Thanks
Reply all
Reply to author
Forward
0 new messages