I have in one activity:
...
double []mylab=new double [100];
public void compute(){
...
double mytime=Double.parseDouble(timing.getText().toString().trim());
//fill array
for (int i=0;i<=mytime;i++){
mylab[i]=Math.exp(i);
//Arrays.fill(mylab,Math.exp(i));
}
...
i.putExtra("mylab",mylab);
startActivity(i);
}
and in the linegraph activity:
...
private double [] mylab =new double [100];
public double [] getmylab(){ return this.mylab;}
public void setmylab(double [] mylab){ this.mylab=mylab;}
...
public void onCreate(Bundle savedInstanceState){
Bundle extras=getIntent().getExtras();
double [] mylab=extras.getDoubleArray("mylab");
setmylab(mylab);
..
public Intent getIntent(Context context){
double []mylab=getmylab();
ArrayList<Double> x =new ArrayList<Double>();
ArrayList<Double> y =new ArrayList<Double>();
//fill x,y values
for (int i=0;i<=20;i++){
x.add(mytime/i);
}
for (int i=0;i<=20;i++){
y.add(mylab[i]);
}
...
I suppose the error lies where i fill the array?
-------------Logcat------------------------------
FATAL EXCEPTION: main E/AndroidRuntime(461):
java.lang.RuntimeException: Unable to start activity ComponentInfo
java.lang.NullPointerException E/AndroidRuntime(461): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime(461): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(461): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(461): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(461): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(461): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(461): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(461): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(461): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(461): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(461): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(461): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime(461): Caused by:
java.lang.NullPointerException E/AndroidRuntime(461): at com...LineGraph.getIntent(LineGraph.java:109) E/AndroidRuntime(461):
at com..LineGraph.onCreate(LineGraph.java:80) E/AndroidRuntime(461):
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(461): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)