views:

46

answers:

0

I'm developing an Android project , the main activity well call a method(Ptime.GetDate) which will change a global variable (output) then this activity will print this variable

public class calendar extends main_menu {

int i=0; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.prayers); final Context con = getBaseContext();

          /* *************** Print ***************/
       pTime.GetDate(0);
       String []  str = new String [18];// = pTime.output;

       for (int ii = 0; ii<18; ii++)
        str[ii] = pTime.output[ii];


            TextView textView = (TextView) findViewById(R.id.Hdate);
      textView.setText(str[0]  );



     //---Button view---
     Button btnOpen = (Button) findViewById(R.id.btnOpen);
        btnOpen.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

             Intent i = new Intent(v.getContext(), NextDate.class);

         startActivity(i);

            }
        });

}

when the user press this button a new intenet will be crated to start nextDate activity.

NextDate.class

public class NextDate  extends main_menu {

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.prayers);

         /* *************** Print ***************/
       pTime.GetDate(0);
 String []  str = pTime.output;

           TextView textView = (TextView) findViewById(R.id.Hdate);
      textView.setText(str[0] );



      TextView textView4 = (TextView) findViewById(R.id.Gdate);
      textView4.setText(" wafa" );

} }

the problem is with pTime.GetDate method because it called in two activities the main activity and the subactivity

What I should do to end the main activity ? or is there any other way to make two activities call the same method

now when I run my program , this error comes out ( the application has stopped unexpectedly)!!!