[Android][Facebook] I can't get anywhere with this

So I am about to literally start pulling my hair out, I spent ages trying to get this thing to import correctly then when I finally did, turned out that Facebook developer section was broken and a fix was under way. So yeah, I got this far and now I am stumped.

I have my game, this is literally the last thing to go in. So I have been following the guide on the documentation and I am at this stage:



	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		View gameView = initializeForView(new Game(), config);
		
//		bottomAd = new AdView(this);
//		topAd = new AdView(this);
//		fullscreenAd = new InterstitialAd(this);
//		
//		bottomAd.setAdUnitId("ca-app-pub-4184436538256601/8061928372");
//		topAd.setAdUnitId("ca-app-pub-4184436538256601/4249007577");
//		fullscreenAd.setAdUnitId("ca-app-pub-4184436538256601/9538661572");
//		
//		bottomAd.setAdSize(AdSize.BANNER);
//		topAd.setAdSize(AdSize.BANNER);
		
		layout = new RelativeLayout(this);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		getWindow().clearFlags(
				WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);


		layout.addView(gameView);
		setContentView(layout);
		
		
		Session.openActiveSession(this, true, new Session.StatusCallback() {
			
			@Override
			public void call(Session session, SessionState state, Exception exception) {
				
				if(session.isOpened()){
					
					Request.newMeRequest(session, new Request.GraphUserCallback() {
						
						@Override
						public void onCompleted(GraphUser user, Response response) {
							if(user != null){
								textView = (TextView) findViewById(R.id.welcome);
								textView.setText("Welcome " + user.getName());
							}
						}
					}).executeAsync();
				}
				
			}
		});
		

	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
	}

}


After getting past a null point that kept claiming my applicationid was null (rebooted eclipse), I am not at this stage.

It started once, had shown the facebook page. Now it won’t run at all, not changed anything. No error message, just straight up “Android Appication has stopped working…”

No idea where to go from here, the documentation isn’t helping. Any ideas?

EDIT: Changed executeAndWait to executeASync, still crashes.

EDIT 2 : Yay debugger, right textView is null. I must be missing something in the XML file. (???)

Does anyone have any idea how to use RestFB or the official FB API? I honestly can’t wrap my head around this, I have the user logged in and no matter what I do I can’t download the profile picture.

Can someone point me to a website/tutorial or something that is not completely vague?

Facebook API will return you a picture URL. You have to do the downloading part manually through that URL. Same goes for G+ friends. It will just tell you the picture URL.

EDIT-----

You need to make a graph path request, with the path of ‘/me/friends’, and add this to the request.


Request request = Request.newGraphPathRequest
request.getParameters().putString("fields", "picture.type(normal)");

Then in the response you can do this:


final JSONArray friendsJson = response.getGraphObject().getInnerJSONObject().getJSONArray("data");

Havent used android facebook api as I go for facebook graph api.


The documentation isn’t that good. It seems like that facebook assumes that you already know how it basically works and just want to look something up ::slight_smile:
Stackoverflow will be your best friend, but after some time you get used to it :wink:

Why I prefer graph api:
I am using libgdx and dont want to write to much platform-specific code.
Graph-api can be easily debuged as most error-messages from facebook contain usefull information, you can even debug it in your browser.

Afterall I havent found any up to date + usefull tutorial, getting facebook running is for try and error commanders as the documentation isnt the best :slight_smile: