Frage

I want to add Scoreloop in my App. I tried it with the official tutorial, but after I wrote my game secret (like the special ID for this site) in the code, eclipse has this problem: "Source not found"

This is my Application Code:

Edit:

Good.

I changed the code. Scoreloop is saying (The tutorial): This code should work. The file exist. But it's still not working.

package com.example.littlepigs;

import android.app.Application;

import com.scoreloop.client.android.ui.ScoreloopManagerSingleton;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ScoreloopManagerSingleton.init(this,
                "SAGk1GZeD3hqJOoThZTWM3YlCFuvgAdZrGgjU6TSCecUw1FnNCJDhw==");
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        ScoreloopManagerSingleton.destroy();
    }

}
War es hilfreich?

Lösung

There is also https://stackoverflow.com/questions/10214659/implementing-scoreloop-on-android?rq=1 Which you should take a look at as it's very similar to yours.

First let's fix the class, you should extend Application not Android.app.Application.

Fix this and copy me the error you get in LogCat have you already create a class called Application that you are extending or is it a base android class?

package com.example.littlepigs;

import com.scoreloop.client.android.ui.ScoreloopManagerSingleton;

public class Application extends Application //not android.app.Application {
    @Override
    public void onCreate() {
            super.onCreate();
            ScoreloopManagerSingleton.init(this, "secret");
    }

@Override
public void onTerminate() {
        super.onTerminate();
        ScoreloopManagerSingleton.destroy();
}

} 

You also don't need to import context, context is saying "what am I doing this as?" So when you pass

ScoreloopManagerSingleton.init(this, "secret");

You are really saying "Start a new ScoreLoopManagerSingleton as Application1"

context is saying "who am I doing this as?"

ScoreloopManagerSingleton.init(this(which would mean Application1's context), "secret")

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top