everyone I am encountering a problem with passing the date from the calendar to my Create_Event.class. Initially the date textView displays “text” then when I click the “Select the date” button the calendar page will show and the date is supposed to be passed to textView that originally displays “text”. I tried coding using intent.putExtra to pass the date from the calendar page to the Create_Events page but I got a force close error due to NullPointerException. Can anyone help me with this issue? Thanks a lot.
For reference, the codes:
Calendar.java
@Override
public void onClick(View view)
{
String date_month_year = (String)view.getTag();
selectedDayMonthYearButton.setText(new StringBuilder().append("Selected:").append(date_month_year));
Intent k = new Intent(Calendar_Event.this, Create_Events.class);
k.putExtra("passdate", date_month_year);
startActivity(k);
Create_Event.java
Intent intent = this.getIntent();
if(intent == null)
{
String strdata = intent.getExtras().getString("passdate");
TextView txtDate = (TextView) findViewById(R.id.textDate);
txtDate.setText(strdata);
}
else
{
}
***Originally the if(intent == null) is if(intent != null), I thought changing it would work but it doesn’t. 😛
Updated the logcat:
09-07 12:03:28.177: E/AndroidRuntime(1033): FATAL EXCEPTION: main
09-07 12:03:28.177: E/AndroidRuntime(1033): java.lang.RuntimeException: Unable to start activity ComponentInfo{main.page/main.page.Create_Events}: java.lang.NullPointerException
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.os.Looper.loop(Looper.java:137)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-07 12:03:28.177: E/AndroidRuntime(1033): at java.lang.reflect.Method.invokeNative(Native Method)
09-07 12:03:28.177: E/AndroidRuntime(1033): at java.lang.reflect.Method.invoke(Method.java:511)
09-07 12:03:28.177: E/AndroidRuntime(1033): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-07 12:03:28.177: E/AndroidRuntime(1033): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-07 12:03:28.177: E/AndroidRuntime(1033): at dalvik.system.NativeStart.main(Native Method)
09-07 12:03:28.177: E/AndroidRuntime(1033): Caused by: java.lang.NullPointerException
09-07 12:03:28.177: E/AndroidRuntime(1033): at main.page.Create_Events.onCreate(Create_Events.java:261)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.Activity.performCreate(Activity.java:4465)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-07 12:03:28.177: E/AndroidRuntime(1033): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)

Any help would be greatly appreciated! Thanks again.
Updated:
Bundle bundle = getIntent().getExtras();
if(bundle != null)
{
String date = bundle.getString("date");
TextView txtDate = (TextView) findViewById(R.id.textDate);
txtDate.setText(date);
}
Use Bundle in Create_Events Activity to get date. Before passing data you first need to check it is null or not.