Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:49:30+00:00 2026-06-14T07:49:30+00:00

As I am new to Android development I am trying to display DatePicker dialog

  • 0

As I am new to Android development I am trying to display DatePicker dialog on Android 2.3.3 emulator,but while it is crashing. I am followed what am I missing to include in my code? But this code is working in Android 4.0.
DatePickerFragment class

public class DatePickerFragment extends DialogFragment implements OnDateSetListener{

 @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    public void onDateSet(DatePicker view, int year, int month, int day) {
        // Do something with the date chosen by the user
    }

}

The activity class that starts the DatePicker Dialog:

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DialogFragment;

import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


@SuppressLint({ "NewApi", "NewApi", "NewApi" })
public class FormAnalysis extends FragmentActivity{

@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fanalysis);
    //getActionBar().setDisplayHomeAsUpEnabled(true);


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.fanalysis, menu);
    return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    //switch (item.getItemId()) {
      //  case android.R.id.home:
        //    NavUtils.navigateUpFromSameTask(this);
            return true;
    //}
    //return super.onOptionsItemSelected(item);
}

public void generate(View view){


}
  public void startDialog(View view){
  DialogFragment newFragment = new DatePickerFragment();
    newFragment.show(getSupportFragmentManager(), "datePicker");} }

Update
Here is the Stack Trace


[2012-11-16 00:31:55 - Food Security] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=kz.bimash.food.security/.Starter }
[2012-11-16 00:31:55 - Food Security] ActivityManager: Warning: Activity not started, its current task has been brought to the front
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:49:31+00:00Added an answer on June 14, 2026 at 7:49 am

    Your DialogFragment import is for the incorrect version of the class. It needs to be android.support.v4.app.DialogFragment instead of android.app.DialogFragment, otherwise it will not work correctly on 2.3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to android development, but I am trying to add admob to
I'm new to android development and I'm trying to code a simple Simon-like game
I'm kinda new to android development, but i'm trying to make a xml parser.
I'm new to Android development and I'm trying to code a little app which
I'm pretty new to Android development, and what I'm trying to do is display
I am new to Android development. I am trying to use the following code
I am new to android development and I've hit a hurdle when trying to
I am new to android development . I'm trying to download and run the
I'm new to Android development, i'm trying to port an IOS app to Android.
I'm new to Android development. My OS is WinXP. I'm trying to install two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.