java.lang.ExceptionInInitializerError调用服务时

时间:2014-03-28 12:07:07

标签: android

当我从eclipse运行我的项目时,它工作得很好。

创建了签名的apk后,我已经在我的设备上进行了测试。它抛出异常。

FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.rvg.app.aws.RegisterService.onCreate(Unknown Source)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2529)

我的SplashScreen类

public class SplashActivity extends BaseFragmentActivity {

    private boolean isDestroyed = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spashscreen);

                 startRegisterService();

        mHandler.sendEmptyMessageDelayed(1,4000l);          
    }

    private void startRegisterService(){
        if(!MyApplication.getSnsPreference().isRegistered()){
            startService(new Intent(this, RegisterService.class));
    }
    }

    @SuppressLint("HandlerLeak")
    private Handler mHandler = new Handler(){
        public void handleMessage(android.os.Message msg) {
            if(msg.what == 1 && !isDestroyed){
                Intent intent;


                if(MyApplication.getUserPrefs().isLoggedIn()){
                    intent = new Intent(SplashActivity.this, HomeActivity.class);
                }
                else{
                    intent = new Intent(SplashActivity.this, WelcomeActivity.class);
                }

                startActivity(intent);
                finish();
            }
        };      
    };


    @Override
    protected void onDestroy() {
        isDestroyed = true;
        super.onDestroy();
    }
}

和我的RegisterService类

public class RegisterService extends Service{

    private PushRegister mRegister;

    @Override
    public void onCreate() {        
        super.onCreate();
        mRegister = new PushRegister(this);
        startRegister();
    }   

    private void startRegister(){
        new AsyncTask<Void, Void, Boolean>(){

            @Override
            protected Boolean doInBackground(Void... params) {
                return mRegister.registerSns();
            }

            protected void onPostExecute(Boolean result) {
                stopSelf();
            }

        }.execute();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

}

如何解决这个问题。 从eclipse运行时没有问题。签名后我已经加载了SD卡并安装。打开应用程序时会崩溃。

问题是什么以及如何解决?

0 个答案:

没有答案