0
votes

I am having an error when trying to switch from one activity(com.intelligent.stocktrader.MyAccount) to another(com.intelligent.stocktrader.SharePerformanceDetails).What am I doing wrong? My code has no error.
Below is the log cat content:

E/AndroidRuntime(787): FATAL EXCEPTION: main E/AndroidRuntime(787): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.intelligent.stocktrader/com.intelligent.stocktrader.SharePerformanceDetails}: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = org.achartengine.chart.LineChart) E/AndroidRuntime(787): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955) E/AndroidRuntime(787): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)

The MyAccount activity onCreate where am switching activities

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_performance);
    //Bundle extras = getIntent().getExtras();
    //stock_name = extras.getString("stock");
    //new PerformanceDetails().execute();   
    LineGraph line=new LineGraph();
    Intent intent=line.getIntent(getApplicationContext());
    startActivity(intent);
}

The LineGraph class

public Intent getIntent(Context context){

    -----------
            -----------
    return intent;
}

The LineGraph class has a method that will return an intent.Tha is where the error is propagating from

3
post your code, there is something with the object that you put in your intentBoris Mocialov
is your activity shareperformancedetails registered in your manifest?karan
probably indicates that your class is not serializable. org.achartengine.chart.LineChartAnhSirk Dasarp
Yes Karan the manifest is up to date.mungaih pk
please post your manifest alsokaran

3 Answers

1
votes

That's because you Intent contain LineChart, which can't be serialized. You shound make LineChart implements from java.io.Serializable.

0
votes

Use following code on onclick() it willl work-

Intent i = new Intent(getApplicationContext(), SecondScreen.class);
StartActivity(i);

To run our application you should enter your new activity in AndroidManifest.xml file. Add new Activity between tags:

<activity android:name=".NewActivityClassName"></activity>
0
votes

Try this:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_performance);
//Bundle extras = getIntent().getExtras();
//stock_name = extras.getString("stock");
//new PerformanceDetails().execute();   
LineGraph line=new LineGraph();
Intent intent=new Intent(getApplicationContext(),SharePerformanceDetails.class); // EDITED
startActivity(intent);

}