This is manifest.xml file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="button.pack" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/ app_name"> <activity android:name=".Activity1" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activity2"></activity> </application> <uses-sdk android:minSdkVersion="8" /> </manifest>
..... Java file: Activity1.Java package button.pack; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Activity1 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); Button next = (Button) findViewById(R.id.Button01); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(), Activity2.class); startActivityForResult(myIntent, 0); } }); } } Java file: Activity2.Java package button.pack; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Activity2 extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); Button next = (Button) findViewById(R.id.Button02); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); } } ................................... Xml Files... main.xml.. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:text="This is Activity 2" /> <Button android:text="Previous" android:id="@+id/Button02" android:layout_width="250px" android:textSize="18px" android:layout_height="55px"> </Button> </LinearLayout> ............................................ main2.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:text="This is Activity 1" /> <Button android:layout_width="250px" android:textSize="18px" android:layout_height="55px" android:id="@+id/Button01" android:text="Next"> </Button> </LinearLayout> .............................................. This my Logcat: 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): FATAL EXCEPTION: main 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): java.lang.RuntimeException: Unable to start activity ComponentInfo{button.pack/button.pack.Activity1}: java.lang.NullPointerException 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 1622) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 1638) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.os.Handler.dispatchMessage(Handler.java:99) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.os.Looper.loop(Looper.java:123) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread.main(ActivityThread.java:3647) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at java.lang.reflect.Method.invokeNative(Native Method) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at java.lang.reflect.Method.invoke(Method.java:507) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:839) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at dalvik.system.NativeStart.main(Native Method) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): Caused by: java.lang.NullPointerException 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at button.pack.Activity1.onCreate(Activity1.java:18) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1047) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 1586) 02-10 13:33:53.962: ERROR/AndroidRuntime(1756): ... 11 more .......................................................... Please Any one find solution for the above scenario..... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en