Reputation: 2288
I am quite noobish with coding as pure hobbyist. I have some experience with C and PHP/mySQL so can sort of read code and maybe get the gist in unfamiliar languages. Any help would be greatly appreciated!
I have recently been trying my hand at android. After playing with ATMEL ICs and AVR programming, it is quite a breather at time...but also I am finding it about 100x more frustrating!
I have a basic login script and activity that should allow a facebook session login via the loginmanager() function (class? Acitvity? View? Fragment? I still have no idea. From C, id call it a function...).
The app requests the relevant permissions as shown, but after now 2 days of trying to figure out why...I can not seem to get anything to occur in the OnComplete() function after the LoginManager() function is called...
Why am I not seeming to get a successful login? Or for that matter...even a "Cancelled" or "Error" login?
package com.j3den.fibre;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.HttpMethod;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SplashScreen extends AppCompatActivity {
List<String> permissionNeeds = Arrays.asList("email","public_profile","user_likes");
String stuff ="";
public static CallbackManager callbackManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("DEBUG ", "================================STARTING=============================================");
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_splash_screen);
super.onCreate(savedInstanceState);
AppEventsLogger.activateApp(this);
LoginManager.getInstance().logInWithReadPermissions(this, permissionNeeds);
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
// ON SUCCESSFUL LOGIN...DO A REQUEST
public void onSuccess(LoginResult loginResult) {
Log.d("DEBUG ", "================================LOGIN SUCCESS=============================================");
TextView infobox = (TextView) findViewById(R.id.textView);
infobox.setText(loginResult.getAccessToken().getUserId());
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
try {
stuff = object.getString("email");
Log.d("CRAP>>>>>>>i>", stuff);
}
catch (JSONException e) {
Log.e("ERR","ERROR!!!!!!!!!!!!!!!!!!!!") ;
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "email,public_profile");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
Log.e("dd", "facebook login canceled");
}
@Override
public void onError(FacebookException error) {
Log.e("dd", "facebook login failed error");
}
}); // Close Login manager
}
}
This is the layout XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.j3den.fibre.SplashScreen"
android:id="@+id/login_button">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="InfoBox"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:editable="true" />
</RelativeLayout>
This is the response in the Log:
W: getTopLevelResources: /data/app/com.j3den.fibre-1/base.apk / 1.0 running in com.j3den.fibre rsrc of package null
W: ClassLoader referenced unknown path: /data/app/com.j3den.fibre-1/lib/arm
W: Failed to open zip archive '/system/framework/com.qti.location.sdk.jar': I/O Error
W: ClassLoader referenced unknown path: /data/app/com.j3den.fibre-1/lib/arm
W: getTopLevelResources: /data/app/com.j3den.fibre-1/base.apk / 1.0 running in com.j3den.fibre rsrc of package null
W: getTopLevelResources: /data/app/com.j3den.fibre-1/base.apk / 1.0 running in com.j3den.fibre rsrc of package null
D: ================================STARTING=============================================
I: (HTTPLog)-Static: isSBSettingEnabled false
I: (HTTPLog)-Static: isSBSettingEnabled false
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/files/AppEventsLogger.persistedevents
W: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/files/AppEventsLogger.persistedsessioninfo
I: Timeline: Activity_launch_request id:com.j3den.fibre time:69519232
D: Metadata value : none
D: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{fc87c3 I.E...... R.....ID 0,0-0,0}
D: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
I: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: (Ia10634f51b)
OpenGL ES Shader Compiler Version: E031.29.00.00
Build Date: 01/28/16 Thu
Local Branch: ss
Remote Branch:
Local Patches:
Reconstruct Branch:
D: eglInitialize EGLDisplay = 0x9e8fa7c4
I: Initialized EGL, version 1.4
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/shared_prefs/com.facebook.sdk.appEventPreferences.xml.bak
W: getTopLevelResources: /data/app/com.j3den.fibre-1/base.apk / 1.0 running in com.j3den.fibre rsrc of package null
D: Warning: Request without access token missing application ID or client token.
I: (HTTPLog)-Static: isSBSettingEnabled false
I: (HTTPLog)-Static: isSBSettingEnabled false
D: Metadata value : none
D: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{dbc56d2 I.E...... R.....I. 0,0-0,0}
D: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
W: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
W: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
D: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
W: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
I: Timeline: Activity_idle id: android.os.BinderProxy@7f76b34 time:69519776
I: Timeline: Activity_idle id: android.os.BinderProxy@6a43772 time:69519776
V: updateVisibility : ActivityRecord{215641b token=android.os.BinderProxy@6a43772 {com.j3den.fibre/com.j3den.fibre.SplashScreen}} show : true
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/shared_prefs/com.facebook.internal.preferences.APP_SETTINGS.xml.bak
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/shared_prefs/com.facebook.sdk.attributionTracking.xml.bak
I: Timeline: Activity_launch_request id:com.facebook.katana time:69521892
V: updateVisibility : ActivityRecord{215641b token=android.os.BinderProxy@6a43772 {com.j3den.fibre/com.j3den.fibre.SplashScreen}} show : false
V: updateVisibility : ActivityRecord{aca09c4 token=android.os.BinderProxy@7f76b34 {com.j3den.fibre/com.facebook.FacebookActivity}} show : false
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/files/AppEventsLogger.persistedevents
I: (HTTPLog)-Static: isSBSettingEnabled false
I: (HTTPLog)-Static: isSBSettingEnabled false
V: updateVisibility : ActivityRecord{215641b token=android.os.BinderProxy@6a43772 {com.j3den.fibre/com.j3den.fibre.SplashScreen}} show : true
W: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
I: Timeline: Activity_idle id: android.os.BinderProxy@6a43772 time:69550856
D: #3 mView = null
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
D: ViewPostImeInputStage processPointer 0
D: ViewPostImeInputStage processPointer 1
V: updateVisibility : ActivityRecord{215641b token=android.os.BinderProxy@6a43772 {com.j3den.fibre/com.j3den.fibre.SplashScreen}} show : false
W: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
I: Timeline: Activity_idle id: android.os.BinderProxy@6a43772 time:69562562
W: remove failed: ENOENT (No such file or directory) : /data/user/0/com.j3den.fibre/files/AppEventsLogger.persistedevents
I: (HTTPLog)-Static: isSBSettingEnabled false
I: (HTTPLog)-Static: isSBSettingEnabled false
Upvotes: 0
Views: 1030
Reputation: 808
Your logcat log is useless, there are no Facebook errors. You probably miss this in your code:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
Please, read Facebook login tutorial.
Upvotes: 1