How to navigate from one activity to another activity - java

i am trying to navigate between different pages on an Android application, when I run the project it takes me to the Emulator screen but an error message appears:
The following is the code in the .java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Spinner spinner = (Spinner)findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.MyPictures, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
final Button button = (Button) findViewById(R.id.button02);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
setContentView(R.layout.imageview);
}
});
}
LogCat:
02-27 11:58:41.374: D/AndroidRuntime(313): Shutting down VM
02-27 11:58:41.374: W/dalvikvm(313): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-27 11:58:41.454: E/AndroidRuntime(313): FATAL EXCEPTION: main
02-27 11:58:41.454: E/AndroidRuntime(313): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.MainActivity}: java.lang.NullPointerException
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.os.Looper.loop(Looper.java:123)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-27 11:58:41.454: E/AndroidRuntime(313): at java.lang.reflect.Method.invokeNative(Native Method)
02-27 11:58:41.454: E/AndroidRuntime(313): at java.lang.reflect.Method.invoke(Method.java:521)
02-27 11:58:41.454: E/AndroidRuntime(313): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-27 11:58:41.454: E/AndroidRuntime(313): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-27 11:58:41.454: E/AndroidRuntime(313): at dalvik.system.NativeStart.main(Native Method)
02-27 11:58:41.454: E/AndroidRuntime(313): Caused by: java.lang.NullPointerException
02-27 11:58:41.454: E/AndroidRuntime(313): at com.example.test.MainActivity.onCreate(MainActivity.java:29)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-27 11:58:41.454: E/AndroidRuntime(313): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-27 11:58:41.454: E/AndroidRuntime(313): ... 11 more
is there any mistake am not aware of ???
this is my second project which shows the same Error
thanks

you have
final Button button = (Button) findViewById(R.id.button02);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
setContentView(R.layout.imageview);
}
});
Remove this setContentView(R.layout.imageview); from button click. also remove final and declare spinner and button globally.
So your button click event should something like this.
final Button button = (Button) findViewById(R.id.button02);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
// Do something here
}
});
basically your full activity goes something like this.
Button button;
Spinner spinner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner = (Spinner)findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.MyPictures, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
button = (Button) findViewById(R.id.button02);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent mSignup = new Intent(activityOne.this, activityTwo.class);
startActivity(mSignup);
}
});
}
If you are using imageview then set it in onCreate method and then try.

Related

how to set listadapter for fragment

I have two framelayout in my main.xml file. I add framelayouts to the class that extends Fragment. my main class extends FragmentActivity and this is Oncreate method of it:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FragmentManager fm =getFragmentManager();
FragmentTransaction ft=fm.beginTransaction();
Fragment f=new Freg1();
Fragment f2=new Freg1();
ft.add(R.id.frame1, f);
ft.add(R.id.frame2, f2);
ft.commit();
tf=Typeface.createFromAsset(this.getAssets(),"font/Byekan.ttf" );
tv1=(TextView) findViewById(R.id.textView1);
tv1.setTypeface(tf);
Log.i(TAG,"1");
lv1=(ListView) findViewById(R.id.listView1);
lv2=(ListView) findViewById(R.id.listView2);
Log.i(TAG,"2");
List<String> stringList = new ArrayList<String>(Arrays.asList(s1));
Log.i(TAG,"3");
ListAdapter listAdapter = new CustomListAdapter(MainActivity.this , R.layout.custom_list ,stringList);
Log.i(TAG,"4");
lv1.setAdapter(listAdapter);
Log.i(TAG,"5");
lv2.setAdapter(listAdapter);
Log.i(TAG,"6");
}
when i run the codes, it crashed after LOG no4. that mean setAdapter() method do not work. how can i resolve this problem?
this is my logcat resource:
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40a13300)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.taxitabriz/com.example.taxitabriz.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.taxitabriz.MainActivity.onCreate(MainActivity.java:55)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
... 11 more
thank for you that help me to resolve problem.
Your ListView lv1 is null as you can see here:
java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: java.lang.NullPointerException
....
com.example.taxitabriz.MainActivity.onCreate(MainActivity.java:55)
The line 55 of MainActivity should be this call: lv1.setAdapter(listAdapter);
Make sure that your listView1 is included within the layout and initialized correctly prior to trying to set an Adapter to it.

Opening a new activity on the click of a button in an Android Application

Here is my problem. I created a button id: "fibo1" . This button belongs to the 'CList' Activity. On clicking the button I would like to open another Activity named ""Fibonacci"
XML of 'CList'
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/fibo1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="Fibo" />
Java of CList
public class CList extends Activity {
Button read1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
read1 = (Button) findViewById (R.id.fibo1);
read1.setOnClickListener (new OnClickListener(){
#Override
public void onClick (View v){
Intent intent = new Intent (CList.this,Fibonacci.class);
startActivity (intent);
finish();
}
});
}
The Application crashes on opening the 'List' activity from the Main Activity. Log Cat gives the error Fatal Exception :main.
I have added both the Activities to the Android Manifest.
I'm just a beginner, so forgive me if my terminology is incorrect.
Here is the Log Cat
03-07 19:33:29.931: E/AndroidRuntime(19565): FATAL EXCEPTION: main
03-07 19:33:29.931: E/AndroidRuntime(19565): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.geek.cprogramspopular/com.geek.cprogramspopular.CList}: java.lang.NullPointerException
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.access$700(ActivityThread.java:150)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.os.Handler.dispatchMessage(Handler.java:99)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.os.Looper.loop(Looper.java:137)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.main(ActivityThread.java:5283)
03-07 19:33:29.931: E/AndroidRuntime(19565): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 19:33:29.931: E/AndroidRuntime(19565): at java.lang.reflect.Method.invoke(Method.java:511)
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
03-07 19:33:29.931: E/AndroidRuntime(19565): at dalvik.system.NativeStart.main(Native Method)
03-07 19:33:29.931: E/AndroidRuntime(19565): Caused by: java.lang.NullPointerException
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.geek.cprogramspopular.CList.onCreate(CList.java:23)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.Activity.performCreate(Activity.java:5283)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
03-07 19:33:29.931: E/AndroidRuntime(19565): ... 11 more
You just remove this line from your XML file and you need not to finish your activity in the Intent Calling...
android:onClick="sendMessage"
read1.setOnClickListener (new OnClickListener(){
#Override
public void onClick (View v){
Intent intent = new Intent (CList.this,Fibonacci.class);
startActivity (intent);
}
});
use the following code -
public void sendMessage(View v) {
Intent intent = new Intent(CList.this, Fibonacci.class);
startAcitivty(intent);
}
after onCreate(Bundle savedInstanceState) method, instead of this -
read1.setOnClickListener (new OnClickListener(){
#Override
public void onClick (View v){
Intent intent = new Intent (CList.this,Fibonacci.class);
startActivity(intent);
finish();
}
you may also remove Button read1; and read1 = (Button) findViewById (R.id.fibo1); after doing this.

java.lang.runtime Exception : unable to start component

I am learning java through a video tutorial but I am having a strange problem I create a class named OpenedClass in java and implements two classes. One is for OnClickListener and 2nd is OnCheckChangeListener but when i run the application on emulator it always give me the error for the calling OnClickListener. The code for my java class is:
package com.thenewboston.thenewboston;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class OpenedClass extends Activity implements View.OnClickListener,
OnCheckedChangeListener {
TextView question, test;
Button returnData;
RadioGroup selectionList;
String gotBread;
String setData;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.send);
initialize();
private void initialize() {
// TODO Auto-generated method stub
question = (TextView) findViewById(R.id.tvQuestion);
test = (TextView) findViewById(R.id.tvTest);
returnData = (Button) findViewById(R.id.bResults);
selectionList = (RadioGroup) findViewById(R.id.rgAnswers);
selectionList.setOnCheckedChangeListener(this);
returnData.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent person = new Intent();
Bundle backpack = new Bundle();
backpack.putString("answer", setData);
person.putExtras(backpack);
setResult(RESULT_OK,person);
finish();
}
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
switch (checkedId) {
case R.id.rCrazy:
setData = "Probably Right !";
break;
case R.id.rSexy:
setData = "Definitely Right !";
break;
case R.id.rBoth:
setData = "Spot On !";
break;
}
test.setText(setData);
}
}
and this is the output for logcat:
01-05 15:59:54.605: E/AndroidRuntime(313): FATAL EXCEPTION: main
01-05 15:59:54.605: E/AndroidRuntime(313): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.thenewboston/com.thenewboston.thenewboston.OpenedClass}: java.lang.NullPointerException
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.os.Handler.dispatchMessage(Handler.java:99)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.os.Looper.loop(Looper.java:123)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-05 15:59:54.605: E/AndroidRuntime(313): at java.lang.reflect.Method.invokeNative(Native Method)
01-05 15:59:54.605: E/AndroidRuntime(313): at java.lang.reflect.Method.invoke(Method.java:507)
01-05 15:59:54.605: E/AndroidRuntime(313): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-05 15:59:54.605: E/AndroidRuntime(313): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-05 15:59:54.605: E/AndroidRuntime(313): at dalvik.system.NativeStart.main(Native Method)
01-05 15:59:54.605: E/AndroidRuntime(313): Caused by: java.lang.NullPointerException
01-05 15:59:54.605: E/AndroidRuntime(313): at com.thenewboston.thenewboston.OpenedClass.initialize(OpenedClass.java:44)
01-05 15:59:54.605: E/AndroidRuntime(313): at com.thenewboston.thenewboston.OpenedClass.onCreate(OpenedClass.java:25)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-05 15:59:54.605: E/AndroidRuntime(313): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-05 15:59:54.605: E/AndroidRuntime(313): ... 11 more
as you guys can see that it tells me that the error is on line 44 and the line 44 in my code is
returnData.setOnClickListener(this);
I did not understand it at all when I comment this line it will show me the layout when I don't it didn't. Any idea why is this happening ?
From your comments below marcin_j post
<Button android:id="#+id/bReturn" // id is bReturn
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Return" >
</Button>
Change this
returnData = (Button) findViewById(R.id.bResults);
to
returnData = (Button) findViewById(R.id.bReturn);

NullPointerException on TabGroupactivity when setting button typeface

I'm having a little problem with an activity I have loading in a TabGroupActivity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_profile);
f = new Functions();
String j = f.getUserInfo();
arialFont = Typeface.createFromAsset(this.getAssets(),"Arial.ttf");
username = (TextView)findViewById(R.id.txtProfileName);
firstname = (TextView)findViewById(R.id.txtName);
Address1 = (TextView)findViewById(R.id.txtAdd1);
Cit = (TextView)findViewById(R.id.txtCity);
PostCode = (TextView)findViewById(R.id.txtPost);
Coun = (TextView)findViewById(R.id.txtCountry);
Phon = (TextView)findViewById(R.id.txtPhone);
dob = (TextView)findViewById(R.id.txtDOB);
gender = (TextView)findViewById(R.id.txtGender);
yourDetails = (Button)findViewById(R.id.Button01);
payment = (Button)findViewById(R.id.Button02);
billing = (Button)findViewById(R.id.Button03);
history = (Button)findViewById(R.id.Button04);
yourDetails.setTypeface(arialFont); <-- Null Pointer exception starts here
payment.setTypeface(arialFont);
billing.setTypeface(arialFont);
history.setTypeface(arialFont);
try {
parseData(j);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The error I recieve from the code is this:
02-27 13:22:47.278: E/AndroidRuntime(929): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Ticketline.Ticketline/com.Ticketline.Ticketline.UserProfile}: java.lang.NullPointerException
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1796)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.TabGroupActivity.startChildActivity(TabGroupActivity.java:61)
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.Account.onCreate(Account.java:33)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Activity.performCreate(Activity.java:4465)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
02-27 13:22:47.278: E/AndroidRuntime(929): ... 18 more
02-27 13:22:47.278: E/AndroidRuntime(929): Caused by: java.lang.NullPointerException
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.UserProfile.onCreate(UserProfile.java:83)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Activity.performCreate(Activity.java:4465)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
02-27 13:22:47.278: E/AndroidRuntime(929): ... 26 more
I know the issue is with setting the buttons typeface to Arial, the problem is I don't understand why this is an issue. If I comment the setTypeface lines out it works fine and will move onto other activity which do have their button typefaces set within the TabGroupActivity which perplexes me even more.
Top marks for anyone that can explain this to me
Figured the issue out, the coder who worked on this app before me gave the history button the id "btnHistory" instead of "Button04". Naturally this resolved in a null pointer error because the id "Button04" doesn't exist in that activity.

Force close error on application when button is pressed

So whenever I click the button on the startup page, it gives me a force close error. Here's the class for the main.xml layout file:
public class ForeverAloneActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnstrt = (Button) findViewById(R.id.toq1);
btnstrt.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Intent frstq = new Intent(v.getContext(), QuestionOne.class);
startActivityForResult(frstq, 0);
And this is what I believe is producing the error. This class is related to the page that that when pressing the button on the startup page, you are taken to:
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView (R.layout.frstq);
Button startQ2 = (Button) findViewById(R.id.toq2);
startQ2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Intent toQ2 = new Intent(v.getContext(), QuestionTwo.class);
final EditText number = (EditText) findViewById(R.id.editText1);
final Toast error = Toast.makeText(QuestionOne.this, "Please insert a value", Toast.LENGTH_SHORT);
if (number.getText().toString().equals("")) {error.show();
}else{
startActivityForResult(toQ2, 0);}
That if statement is there as on the next page, there is an EditText box. I tried to make it so that if there is nothing in the EditText box, it displays a toast message saying "Please insert a value". Until an integer is put into the EditText box, then the button will not work.
If someone can help, it will be much appreciated.
Logcat:
04-07 19:33:58.199: W/dalvikvm(362): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-07 19:33:58.221: E/AndroidRuntime(362): FATAL EXCEPTION: main
04-07 19:33:58.221: E/AndroidRuntime(362): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.kenning.foreveralone/com.kenning.foreveralone.QuestionOne}; have you declared this activity in your AndroidManifest.xml?
04-07 19:33:58.221: E/AndroidRuntime(362): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-07 19:33:58.221: E/AndroidRuntime(362): at com.kenning.foreveralone.ForeverAloneActivity$1.onClick(ForeverAloneActivity.java:22)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.view.View.performClick(View.java:2408)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.view.View$PerformClick.run(View.java:8816)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.os.Handler.handleCallback(Handler.java:587)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.os.Handler.dispatchMessage(Handler.java:92)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.os.Looper.loop(Looper.java:123)
04-07 19:33:58.221: E/AndroidRuntime(362): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-07 19:33:58.221: E/AndroidRuntime(362): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 19:33:58.221: E/AndroidRuntime(362): at java.lang.reflect.Method.invoke(Method.java:521)
04-07 19:33:58.221: E/AndroidRuntime(362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-07 19:33:58.221: E/AndroidRuntime(362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-07 19:33:58.221: E/AndroidRuntime(362): at dalvik.system.NativeStart.main(Native Method)
are you adding QuestionTwo in manifiest file ?
check your error - have you declared this activity in your AndroidManifest.xml?
Declare your activity in manifeast file. It seems you forgetted that
<activity android:name="QuestionTwo" />
also dont forget to include every activity in your manifeast file
Hey have you added the QuestionTwo class as an activity in menifest file. If after adding the
Intent toQ2 = new Intent(YourCurrentActivity.this,QuestionTwo.class);
then you must have not added the activity in menifest.B'coz it clearly shows in the log that Activity is not found. You have to declare the activity in menifest file.
Hope you'll get run your app.

Categories