2

I am trying to call new page from main activity. Main activity has Button, onClick of the button I am launching the new page as below

@Override
public void onClick(View arg0) {
  if(arg0.getId() == R.id.buttonSearch){
        //define a new Intent for the second Activity
        Intent intent = new Intent(this,SearchActivity.class);
        //start the second Activity
        this.startActivity(intent);
    }
}

while loading the new page i am getting an error at :

this.setContentView(R.layout.searchm);

BELOW IS CODE OF LOADING PAGE

public class SearchActivity extends Activity   {

 Context context;    
 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.searchm);

THE LOGCAT IS AS BELOW

    09-09 14:05:23.766: E/MapActivity(1163): Couldn't get connection factory client
    09-09 14:11:22.036: E/AndroidRuntime(1163): FATAL EXCEPTION: main
    09-09 14:11:22.036: E/AndroidRuntime(1163): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.googlemaps/com.androidhive.googlemaps.SearchActivity}: java.lang.NullPointerException
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.os.Looper.loop(Looper.java:137)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at java.lang.reflect.Method.invoke(Method.java:525)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at dalvik.system.NativeStart.main(Native Method)
    09-09 14:11:22.036: E/AndroidRuntime(1163): Caused by: java.lang.NullPointerException
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at com.androidhive.googlemaps.SearchActivity.onCreate(SearchActivity.java:113)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.Activity.performCreate(Activity.java:5133)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    09-09 14:11:22.036: E/AndroidRuntime(1163):     ... 11 more
    09-09 14:14:15.676: E/MapActivity(1226): Couldn't get connection factory client
    09-09 14:14:27.676: E/AndroidRuntime(1226): FATAL EXCEPTION: main
    09-09 14:14:27.676: E/AndroidRuntime(1226): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.googlemaps/com.androidhive.googlemaps.SearchActivity}: java.lang.NullPointerException
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.os.Looper.loop(Looper.java:137)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at java.lang.reflect.Method.invoke(Method.java:525)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at dalvik.system.NativeStart.main(Native Method)
    09-09 14:14:27.676: E/AndroidRuntime(1226): Caused by: java.lang.NullPointerException
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at com.androidhive.googlemaps.SearchActivity.onCreate(SearchActivity.java:113)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.Activity.performCreate(Activity.java:5133)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    09-09 14:14:27.676: E/AndroidRuntime(1226):     ... 11 more
    09-09 14:16:15.239: E/AndroidRuntime(1288): FATAL EXCEPTION: main
    09-09 14:16:15.239: E/AndroidRuntime(1288): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.googlemaps/com.androidhive.googlemaps.AndroidGoogleMapsActivity}: java.lang.NullPointerException
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.os.Looper.loop(Looper.java:137)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at java.lang.reflect.Method.invoke(Method.java:525)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at dalvik.system.NativeStart.main(Native Method)
    09-09 14:16:15.239: E/AndroidRuntime(1288): Caused by: java.lang.NullPointerException
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at com.androidhive.googlemaps.AndroidGoogleMapsActivity.onCreate(AndroidGoogleMapsActivity.java:36)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.Activity.performCreate(Activity.java:5133)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    09-09 14:16:15.239: E/AndroidRuntime(1288):     ... 11 more
    09-09 14:29:01.106: E/MapActivity(1344): Couldn't get connection factory client
    09-09 14:29:12.417: E/AndroidRuntime(1344): FATAL EXCEPTION: main
    09-09 14:29:12.417: E/AndroidRuntime(1344): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.googlemaps/com.androidhive.googlemaps.SearchActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class CustomAutoCompleteTextView
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.os.Looper.loop(Looper.java:137)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at java.lang.reflect.Method.invoke(Method.java:525)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at dalvik.system.NativeStart.main(Native Method)
    09-09 14:29:12.417: E/AndroidRuntime(1344): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class CustomAutoCompleteTextView
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.Activity.setContentView(Activity.java:1895)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at com.androidhive.googlemaps.SearchActivity.onCreate(SearchActivity.java:27)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.Activity.performCreate(Activity.java:5133)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     ... 11 more
    09-09 14:29:12.417: E/AndroidRuntime(1344): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CustomAutoCompleteTextView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.androidhive.googlemaps-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.androidhive.googlemaps-1, /vendor/lib, /system/lib]]
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
    09-09 14:29:12.417: E/AndroidRuntime(1344):     ... 21 mor

e
3
  • please edit and put logfile inside a code block - this is too hard to read. also the this.setContentView(R.layout.searchm); looks whacky to me... Commented Sep 9, 2013 at 18:41
  • in your layout file which has Autocomplete textView, change it to your package. Commented Sep 9, 2013 at 19:06
  • Have you using map there ? Commented Sep 10, 2013 at 3:47

2 Answers 2

2

Change your CustomAutoCompleteTextView XML to

From

<android.view.CustomAutoCompleteTextView
    ... 
    android:id="@+id/autocomplete"/>

to

<com.yourpackage.CustomAutoCompleteTextView 
    ... 
    android:id="@+id/autocomplete"/>
Sign up to request clarification or add additional context in comments.

Comments

0

From your main activity do this to start a new Intent since it is inside an onclick

    Intent intent = new Intent(MainActivity.this,SearchActivity.class);
    //start the second Activity
    startActivity(intent);

And inside your SearchActivity set the contentview like this...

    super.onCreate(savedInstanceState);
    setContentView(R.layout.searchm);

Also check your manifest whether you have registered both these activities or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.