I got an null pointer exception on Android 3.2 emulator on a simple
Android project created by Wizerd with a service in separated process,
when I switch between "Stretch to fill screen" to "Zoom to fill
screen". This crash will *not* happen if the service is put into the
same process with main activity, namely "android:process" attribute
not specified. While it only happens when I add "android:process" to
manifest file for my test service.

The exception is:

FATAL EXCEPTION: main
      java.lang.NullPointerException
       at
android.view.WindowManagerImpl.reportNewConfiguration(WindowManagerImpl.java:
427)
       at
android.app.ActivityThread.handleUpdatePackageCompatibilityInfo(ActivityThread.java:
2801)
      at android.app.ActivityThread.access$2700(ActivityThread.java:
122)
      at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1151)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:132)
      at android.app.ActivityThread.main(ActivityThread.java:4123)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:491)
      at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
      at dalvik.system.NativeStart.main(Native Method) My test code:

TestActivity.java (Generated by Wizerd)
=====================
package com.test;

import android.app.Activity;

public class TestActivity extends Activity {
    @Override     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         Intent intent = new Intent(this, TestService.class);
         startService(intent);
} }
=====================

TestService.java (Most of the functions are empty)
=====================
Package com.test;

import android.content.ComponentName;

public class TestService extends Service {
     private boolean m_connected = false;
     private ServiceConnection m_connInitService = new
ServiceConnection() {
         public void onServiceConnection(ComponentName className,
IBinder service) {
                       m_connected = true;
         }
         public void onServiceDisconnected(ComponentName className) {
         }
     };

     public static class TestServiceBinder extends Binder {
     }

     public IBinder onBind(Intent intent) {
         return new TestServiceBinder();
     }

     public void onDestroy() {
         super.onDestroy();
     }

     public int onStartCommand(Intent intent, int flags, int startId)
{
         return 1;
     }
 }
=====================

If I run the test app without service or with service in the same
process (with main activity) the screen compatibility switch will
*not* cause any problem. However, I do not understand why service can
cause system exception during screen compatibility switch. Is this
because service process is a non-UI process? Which could potentially
triggers a bug inside the Android core code?

-- 
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

Reply via email to