java - No empty constructor: android class -


my problem is, transferring 2 arrays between activities. return 1 activity. there getting these 2 activities constructor( think ). correct? why getting error: no empty constructor?

here class activites coming from:

public planoutputactivity fetchallroutes(string startstop, string endstop, string time) { . . . return new planoutputactivity(convertarray(),routenarray); 

here activity wanna these 2 arrays:

public class planoutputactivity extends activity {      intent intent;     object[][] routenarray;     string[][] itemsarray;     databasehelperactivity mdbh;     public int result_ok = 123;     public int request_ok = 456;      public planoutputactivity(string[][] itemsarray, string[][] routenarray){         setcontentview(r.layout.planoutputlayout);         this.routenarray = routenarray;         this.itemsarray = itemsarray;     }      @override     protected void oncreate(bundle savedinstancestate) {         // todo auto-generated constructor stub         super.oncreate(savedinstancestate);      }      public void getroute() {          intent = getintent();         mdbh = new databasehelperactivity(this);         mdbh.fetchallroutes(intent.getstringextra("starthaltestelle"),intent.getstringextra("zielhaltestelle"),intent.getstringextra("zeit"));       listview lvlist = (listview)findviewbyid(r.id.listoutput);         arrayadapter<definerouteactivity> adapter = new routeadapteractivity(this, route);         lvlist.setadapter(adapter);          lvlist.setonitemclicklistener(new adapterview.onitemclicklistener() {             @override             public void onitemclick(adapterview<?> adapterview, view view, int i, long l) {                 int gkennung = view.getid();                 intent intent = new intent(getapplicationcontext(),detailoutputactivity.class);                 intent.putextra("kennung",gkennung);                 intent.putextra("routenarray",routenarray);                 intent.setflags(intent.flag_activity_new_task);                 startactivity(intent);             }         });     } 

you can't create instance of android activity using new - doesn't work.

the ways create activity either when launched apps launcher or if call startactivity(...) (or 1 of other methods such startactivityforresult(...) etc).

because of shouldn't ever create constructors activity , should never create public static fields or methods intention of accessing data or calling methods in activity other application class.

if want pass data 1 activity using extras in intent or persist data in sharedpreferences or database. alternatively create 'helper' class hold data - using singleton pattern quite common this.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -