Exception in DatePickerDialog

Posted by Miya on Stack Overflow See other posts from Stack Overflow or by Miya
Published on 2011-01-10T06:29:28Z Indexed on 2011/01/10 6:53 UTC
Read the original article Hit count: 245

Filed under:
|
|

Hi,

i am trying to create a DatePickerDialog in the class 'dateDisplay.class'. I am calling this activity from 'main.class'. If I call the 'dateDisplay.class' using startActivity(), then the DatePickerDialog works fine. But actually I am using an ActivityGroup (for using tab in my application) and I am starting the 'dateDisplay.class' using the following code :

    Intent dateIntent=new Intent(context,dateDisplay.class);
    View v=getLocalActivityManager().startActivity("2",dateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
    setContentView(v);

But an exception is caught, on calling the onCreateDialog() function. And the process is suddently stopped. It shows TargetInvocationException is occured. How can I correct the code? Following is my code:

public  Dialog onCreateDialog(int id,Bundle b)
     {
       Calendar c=Calendar.getInstance();
       int day=c.get(Calendar.DAY_OF_MONTH);
       int month=c.get(Calendar.MONTH);
       int year=c.get(Calendar.YEAR);
       Dialog d = null;
       if(id==DATE_DIALOG_ID)
       {
          return    new DatePickerDialog(this,dateChangeListener,year,month,day); 
       }

       else
       {
               return null;
         }


     }

Please help me.. Thank you..

© Stack Overflow or respective owner

Related posts about android

Related posts about exception