Hi,

I have the following test code which calls
callActivityOnRestoreInstanceState of Instrumentation class.
 mStartIntent = new Intent(Intent.ACTION_MAIN);
        Bundle bundle = new Bundle();
                bundle.putBoolean("testProperty", false);
                
                MyActivity myActivity = startActivity(mStartIntent, null, null);
                
                getInstrumentation().callActivityOnStart(myActivity);
                
                
getInstrumentation().callActivityOnRestoreInstanceState(myActivity, bundle);

But when I run the unit test with instrumentation, i get this error:
ndroid.util.AndroidRuntimeException: Acquiring SearchManager objects
only valid in Activity Contexts.
        at 
android.app.ApplicationContext.getSearchManager(ApplicationContext.java:976)
        at 
android.app.ApplicationContext.getSystemService(ApplicationContext.java:861)
        at 
android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:73)
        at android.app.Activity.getSystemService(Activity.java:3091)
        at android.app.Activity.performRestoreInstanceState(Activity.java:797)
        at 
android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1171)
        at 
com.mycompany.TestMyActivity.testSaveRestoreInstanceState(TestMyActivity.java:79)

Can you please tell me what am I missing in setting up my instrumentation?

Thank you.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to