my class code is here :

public class Application {
    private static final String TAG = "fset.entrance.Application";
    public static Frame froot=null;

    public static void initial(){
        if (froot != null){
            return ;
        }
        froot = new Frame("fset","FrameSet");
    }
}

my activity is here

public class FrameEntranceActivity extends Activity {
    private static final String TAG = "fset.entrance.FrameEntranceActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Application.initial();
    }
}

logcat of android is here

09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.os.Looper.loop(Looper.java:137)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread.main(ActivityThread.java:5039)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at java.lang.reflect.Method.invokeNative(Native Method)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at java.lang.reflect.Method.invoke(Method.java:511)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at dalvik.system.NativeStart.main(Native Method)
09-05 02:00:28.350: E/AndroidRuntime(1891): Caused by: java.lang.NullPointerException
09-05 02:00:28.350: E/AndroidRuntime(1891):     at fset.entrance.Application.initial(Application.java:12)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at fset.entrance.FrameEntranceActivity.onCreate(FrameEntranceActivity.java:22)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.Activity.performCreate(Activity.java:5104)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-05 02:00:28.350: E/AndroidRuntime(1891):     ... 11 more

After finding solutions from stackoverflow , I learned that not any static variable could be created successly when AVD start , but, I have no idea about these rules systemly, I want some help could clarify my incomplete understanding .

Related posts

Recent Viewed