0

I'm trying to make a daydream that uses the Facebook SDK with Android-Simple-Facebook.

Daydreams run as a service and has no associated activity as far as I am aware. I'm having an issue where I need to pass an Activity (not a context...) through to Android-Simple-Facebook, which passes it to the Facebook SDK. I drilled through some of the methods and found this one to to be the issue:

public UiLifecycleHelper(android.app.Activity activity
    com.facebook.Session.StatusCallback callback) { /* compiled code */ }

I am not sure how I can use this anymore if I don't have an activity. I can understand using this to help with the "lifecycle" but it seems like a terrible decision to use Activity instead of Context.

The code that doesn't work in mine is:

mSimpleFacebook = SimpleFacebook.getInstance(this); //this needs to be activity, 
    not DreamService, which extends Context

I tried

Activity activity = new Activity();
mSimpleFacebook = SimpleFacebook.getInstance(activity);

but further down the line its trying to get a context which it can't.

java.lang.NullPointerException: Attempt to invoke virtual method 
'android.content.Context android.content.Context.getApplicationContext()' 
on a null object reference

Anyone have any ideas? This is going to be a serious dealbreaker if I can't get it to work.

Mgamerz
  • 2,872
  • 2
  • 27
  • 48
  • To make any request to facebook side, you have to get `accessToken`. Once you have it, you can do most of actions without `Activity` at all. To get the `accessToken` you need to take the user through login process with login dialog and stuff like this. So my question, how and where will you do the login process? – sromku May 21 '14 at 19:05
  • I have that in the settings activity. That part works fine, your project works well for that. But the main SimpleFacebook() method that gets an instance requires an Activity parameter. – Mgamerz May 21 '14 at 19:37
  • 1
    I see, you are right,.. ok, I will need to do some small changes to support this scenario – sromku May 21 '14 at 19:41
  • 1
    I'm using v2.0 of your repo. Thanks! – Mgamerz May 21 '14 at 19:42

0 Answers0