Skip to content Skip to sidebar Skip to footer

Android - How To Make Plot With User Data

I have a program which makes some calculations according to user data. The program works fine ,but when i try to use achartengine in order to make the plot ,it crashes.(doesn't do

Solution 1:

Bundle approach:

Intent searchIntent = newIntent();        
searchIntent.setClassName("com.mypackage",searrchActivity.class.getName());                 
searchIntent.putExtra("value", initcores); // key/value pair, where key needs current package prefix.                   
searchIntent.putExtra("value2", fcores);
thisactivity.startActivity(searchIntent);  

and in your LineGraph activity:

classLineGraphextendsActivity{
   privateDouble initcores;
   privateDouble fcores;

   publicDoublegetInitcores(){ returnthis.initcores;} 
   publicvoidsetInitcores(Double initcores){ this.initcores=initcores;} 
   publicDoublegetFcores(){ returnthis.fcores;} 
   publicvoidsetFcores(Double fcores){ this.fcores=fcores;} 


   publicvoidonCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    ......
    Bundle extras = getIntent().getExtras(); 
    Double initcores= extras.getDouble("value"); 
    setInitcores(initcores); 
    Double fcores= extras.getDouble("value2"));
    setFcores(fcores);

    }
  publicIntentgetIntent(...){
                  Double initcores= getInitcores();
                  Double fcores= getFcores();
           //yourcode 
  }
}

SharedPreferences approach:

SharedPreferencessp=PreferenceManager.getDefaultSharedPreferences(this);      
    SharedPreferences.Editor ed= sp.edit();
    ed.putInt("screen_width", 480);     
    ed.commit();        

and in your next activity

SharedPreferencessp= PreferenceManager.getDefaultSharedPreferences(this);
    intwidth= sp.getInt("screen_width",default_int_value);

hope this helps abit

Post a Comment for "Android - How To Make Plot With User Data"