无法启动接收器vc908.stickerfactory.receiver.AnalyticsTaskReceiver:vc908.stickerfactory.p $ b

时间:2016-03-03 16:22:24

标签: android android-studio quickblox

我已经尝试了这个:Integrating Quickblox Android SDK for Chat并且它有效。 经过一些修改后,这个错误再次出现。

03-03 23:01:34.002 24168-24168/? E/AndroidRuntime: FATAL EXCEPTION: main
                                               java.lang.RuntimeException: Unable to start receiver vc908.stickerfactory.receiver.AnalyticsTaskReceiver: vc908.stickerfactory.p$b: Storage manager not initialized. Use init(...) method before.
                                                   at android.app.ActivityThread.handleReceiver(ActivityThread.java:2520)
                                                   at android.app.ActivityThread.access$1500(ActivityThread.java:156)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1416)
                                                   at android.os.Handler.dispatchMessage(Handler.java:99)
                                                   at android.os.Looper.loop(Looper.java:153)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                   at java.lang.reflect.Method.invoke(Method.java:511)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                   at dalvik.system.NativeStart.main(Native Method)
                                                Caused by: vc908.stickerfactory.p$b: Storage manager not initialized. Use init(...) method before.
                                                   at vc908.stickerfactory.p.a(Unknown Source)
                                                   at vc908.stickerfactory.receiver.AnalyticsTaskReceiver.onReceive(Unknown Source)
                                                   at android.app.ActivityThread.handleReceiver(ActivityThread.java:2513)
                                                   at android.app.ActivityThread.access$1500(ActivityThread.java:156) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1416) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                   at android.os.Looper.loop(Looper.java:153) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                   at java.lang.reflect.Method.invokeNative(Native Method) 
                                                   at java.lang.reflect.Method.invoke(Method.java:511) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                   at dalvik.system.NativeStart.main(Native Method) 

以下是错误发生的地方:

package com.example.user.nannywatch.chat.ui.activities;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.example.user.nannywatch.MainMenu;
import com.example.user.nannywatch.R;
import com.quickblox.core.QBEntityCallbackImpl;
import com.example.user.nannywatch.chat.core.ChatService;
import com.quickblox.core.QBSettings;
import com.quickblox.users.model.QBUser;

import java.util.List;

import vc908.stickerfactory.StickersManager;

public class LoginActivity extends Activity {

    public static final String USER_LOGIN = "userLogin";
    public static final String USER_PASSWORD = "userPassword";
    public static final String PREFS = "PreferencesFile";
    public static final String APP_ID = "XXXX";
    public static final String AUTH_KEY = "XXXXXXXXXX";
    public static final String AUTH_SECRET = "XXXXXXXXX";
    public static final String PROPERTY_REG_ID = "XXXXXXX";
    public static final String STICKER_API_KEY = "847b82c49db21ecec88c510e377b452c";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String userLogin = null;
        String userPassword = null;

        QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SECRET);

        SharedPreferences settings = getSharedPreferences(LoginActivity.PREFS, 0);
        userLogin = settings.getString(USER_LOGIN, userLogin);
        userPassword = settings.getString(USER_PASSWORD,userPassword);

        if(settings.contains(USER_LOGIN) && settings.contains(USER_PASSWORD) /*&& settings.contains(PROPERTY_REG_ID)*/ && !userLogin.isEmpty() && !userPassword.isEmpty() /*&& !regId.isEmpty()*/){
            final QBUser user = new QBUser();
            user.setLogin(userLogin);
            user.setPassword(userPassword);

            ChatService.initIfNeed(this);

            ChatService.getInstance().login(user, new QBEntityCallbackImpl() {

                @Override
                public void onSuccess() {
                    Intent intent = new Intent(getApplicationContext(), MainMenu.class);
                    startActivity(intent);
                    Toast.makeText(LoginActivity.this, "Logged in as: " + user.getLogin(), Toast.LENGTH_SHORT).show();
                    finish();
                }

                @Override
                public void onError(List errors) {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(LoginActivity.this);
                    dialog.setMessage("chat login errors: " + errors).create().show();
                }
            });
            this.finish();
        }

        setContentView(R.layout.activity_splash);
        StickersManager.initialize(STICKER_API_KEY, this);
    }

    public void login(View view){
        // Login to REST API
        //

        final RelativeLayout loggingIn = (RelativeLayout) this.findViewById(R.id.logging_in);
        loggingIn.setVisibility(View.VISIBLE);

        final QBUser user = new QBUser();

        EditText login = (EditText) this.findViewById(R.id.username);
        EditText password = (EditText) this.findViewById(R.id.password);

        user.setLogin(login.getText().toString());
        user.setPassword(password.getText().toString());

        ChatService.initIfNeed(this);

        ChatService.getInstance().login(user, new QBEntityCallbackImpl() {

            @Override
            public void onSuccess() {
                // Go to Dialogs screen

                SharedPreferences settings = getSharedPreferences(PREFS, 0);
                SharedPreferences.Editor editor = settings.edit();
                editor.putString("userLogin", user.getLogin());
                editor.commit();
                editor.putString("userPassword", user.getPassword());
                editor.commit();

                Intent intent = new Intent(getApplicationContext(), MainMenu.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onError(List errors) {
                loggingIn.setVisibility(View.GONE);
                AlertDialog.Builder dialog = new AlertDialog.Builder(LoginActivity.this);
                dialog.setMessage("chat login errors: " + errors).create().show();
            }
        });
    }
    public void doNothing(View view){

    }
}

我已经在AndroidManifest中正确编写了提供程序。

<provider
        android:name="vc908.stickerfactory.provider.StickersProvider"
        android:authorities="com.example.user.nannywatch.stickersProvider"
        android:exported="false" />

知道为什么它不起作用?

0 个答案:

没有答案