简体   繁体   中英

i am using parse.com as backend when i start app Unfortunately stopped error occurs ,see datails below thanks

i am using Parse.com as my backend on android platform ,in which i created application class extends application and initialized app key ,client key that stuff class code is below

public class Application extends android.app.Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(this, getString(R.string.app_id), getString(R.string.client_id));
        Parse.enableLocalDatastore(this);

        ParseInstallation.getCurrentInstallation().saveInBackground();
    }
}

and also created a launcher activity code is below

public class Splash extends AppCompatActivity {
    Button signup, login;
    ProgressBar progressBar;
    public static Activity fa;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        fa=this;

        signup = (Button) findViewById(R.id.signupbutton);
        login = (Button) findViewById(R.id.loginbutton);
        progressBar = (ProgressBar) findViewById(R.id.progressBar);
        signup.setVisibility(View.INVISIBLE);
        login.setVisibility(View.INVISIBLE);

        if (AppStatus.getInstance(this).isOnline()) {


                ParseUser currentUser = ParseUser.getCurrentUser();
                if (currentUser != null) {
                    Intent intent = new Intent(this, HomePage.class);
                    startActivity(intent);
                    finish();

                } else {
                    progressBar.setVisibility(View.GONE);
                    signup.setVisibility(View.VISIBLE);
                    login.setVisibility(View.VISIBLE);
                    signup.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(Splash.this, Signup.class);
                            startActivity(intent);
                        }
                    });
                    login.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(Splash.this, LogIn.class);
                            startActivity(intent);
                        }
                    });

                }


        } else {
            FragmentManager manager = getSupportFragmentManager();
            mydig mydig = new mydig();
            mydig.setCancelable(false);
            mydig.show(manager, "mydig");

        }
    }




}

now when i start app app gets gets error unfortunately stopped,error shown by logcat is below

08-29 14:30:30.253  26799-26799/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.nintysixkmdev.supercollege, PID: 26799
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nintysixkmdev.supercollege/com.nintysixkmdev.supercollege.Splash}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
            at com.parse.Parse.getParseDir(Parse.java:304)
            at com.parse.ParseObject.getFromDisk(ParseObject.java:667)
            at com.parse.ParseUser$10.then(ParseUser.java:1056)
            at com.parse.ParseUser$10.then(ParseUser.java:1003)
            at bolts.Task$14.run(Task.java:796)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeAfterTask(Task.java:787)
            at bolts.Task.continueWithTask(Task.java:599)
            at bolts.Task.continueWithTask(Task.java:610)
            at com.parse.ParseUser.getCurrentUserAsync(ParseUser.java:1003)
            at com.parse.ParseUser.access$800(ParseUser.java:26)
            at com.parse.ParseUser$9.then(ParseUser.java:996)
            at com.parse.ParseUser$9.then(ParseUser.java:993)
            at com.parse.TaskQueue.enqueue(TaskQueue.java:61)
            at com.parse.ParseUser.getCurrentUserAsync(ParseUser.java:993)
            at com.parse.ParseUser.getCurrentUser(ParseUser.java:979)
            at com.parse.ParseUser.getCurrentUser(ParseUser.java:966)
            at com.nintysixkmdev.supercollege.Splash.onCreate(Splash.java:40)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

can anyone tell me problem in my code. Thanks

i named Class As Application n Also Extended Application i think there is the prob. when i changed name of class my code worked Thanks all of you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM