Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Start New Activity

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I start new activity from an activity. I want to start a new activity from on click listener. Basically, I have a class that extends "Activity" and I would like to call its onClick method but I do not have a Bundle object available.

Thanks
Imad
 
Pratik Goswami
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Imad,

Just use,


Thanks
Pratik Goswami
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should consider reading this and maybe bookmark it. You can find answer to your question under the question: Opening a new screen
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply. Now I am getting following error although I have added activity to my manifest file.

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.imad.futureValue/FutureValueFunction}; have you declared this activity in your AndroidManifest.xml?

Here is my manifest file. Future Value is actually started by payment function.

Thanks
Imad

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.imad.paymentFunction"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PaymentFunction"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="com.android.imad.futureValue.FutureValueFunction"
android:label="@string/fvText">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="6" />

</manifest>
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things :
1. Use code tags when posting code, it improves readability.(You can use the Edit Button)
2. Note that only one of the activity should be having :
in their intent filter, other wise you will see two different icons for your application in the Launcher menu.
3. Can you also post the code you used to start the new Activity?
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Monu. I resolved this problem and this is how I am doing it now.



and in my java file I have


Would you like to add any suggestion to this?
Thanks
Imad
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks good to me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic