private void onClickLogin() { Session session = Session.getActiveSession(); if (!session.isOpened() && !session.isClosed()) { session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback)); } else { Session.openActiveSession(this, true, statusCallback); } }
public void onClickLogin() { Session session = Session.getActiveSession(); if (!session.isOpened() && !session.isClosed()) { session.openForRead( new Session.OpenRequest(mContext).setPermissions(this.mPermissions).setCallback(this)); } else { Session.openActiveSession(mContext, true, this); } }
public void loginWithFacebook() { // TipsManager.setIsJustLogined(true); Session session = Session.getActiveSession(); if (!session.isOpened() && !session.isClosed()) { session.openForRead(new Session.OpenRequest(activity).setCallback(facebookStatusCallback)); } else { Session.openActiveSession(activity, true, facebookStatusCallback); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_nfmain); mInfoText = (TextView) findViewById(R.id.textView); // Check for available NFC Adapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null) { mInfoText = (TextView) findViewById(R.id.textView); mInfoText.setText("NFC is not available on this device."); } else { // Register callback to set NDEF message mNfcAdapter.setNdefPushMessageCallback(this, this); // Register callback to listen for message-sent success mNfcAdapter.setOnNdefPushCompleteCallback(this, this); } // start Facebook Login Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { // make request to the /me API Request.executeMeRequestAsync( session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { Toast.makeText( getApplicationContext(), "Welcome " + user.getName() + " : " + user.getId() + "!", Toast.LENGTH_LONG) .show(); userId = user.getId(); } } }); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { PackageInfo info = getPackageManager() .getPackageInfo("com.whatever.webviewtest", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } // start Facebook Login Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { currentSession = session; // make request to the /me API Request.newMeRequest( session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { Log.d("ASDF", "SUCCESSFULLY LOGGED IN " + response + " " + user); userInfo = user; setupWebview(); } else { Toast.makeText( MainActivity.this, "Facebook login failed", Toast.LENGTH_SHORT) .show(); } } }) .executeAsync(); } } }); }
private boolean ensureOpenSession() { if (Session.getActiveSession() == null || !Session.getActiveSession().isOpened()) { Session.openActiveSession( this, true, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { onSessionStateChanged(session, state, exception); } }); return false; } return true; }
@Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); mHelper.onResume(); if (!hasTryLogin) { if (FacebookUtil.isFacebookVlidate(this)) mAction = PendingAction.NONE; else mAction = PendingAction.GET_INFO; Session session = Session.getActiveSession(); if (session != null && (!session.isOpened() && !session.isClosed())) { session.openForRead( new Session.OpenRequest(this).setPermissions(null).setCallback(mCallback)); } else { Session.openActiveSession(this, true, mCallback); } } }
public void fbLogin() { Session.openActiveSession( this, true, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); p.edit().putBoolean("loggedIn", true).commit(); Intent intent = new Intent(MainActivity.this, NieuwsOverzichtActivity.class); intent.putExtra("newscategory", "algemeen"); startActivity(intent); } } }); }
public static void openSession(final Activity activity) { if (com.facebook.Session.getActiveSession() != null) { closeSession(); } com.facebook.Session.openActiveSession( activity, true, new StatusCallback() { @Override public void call(com.facebook.Session session, SessionState state, Exception exception) { // TODO Auto-generated method stub statusCallback.call(session, state, exception); List<String> permissions = session.getPermissions(); if (session != null && session.isOpened() && !permissions.containsAll(PERMISSIONS)) { requestPublishPermissions(activity, session); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // start Facebook Login Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { // make request to the /me API Request.executeMeRequestAsync( session, new Request.GraphUserCallback() { TextView welcome = (TextView) findViewById(R.id.sign_in_status); // callback after Graph API response with user // object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { welcome.setText("Hello " + user.getName() + "!"); Log.d(FacebookActivity.class.getCanonicalName(), user.getName()); } else { welcome.setText("Foo is bar as bar is foo"); Log.d(FacebookActivity.class.getCanonicalName(), "F**k U"); } } }); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); // start Facebook Login Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { // make request to the /me API Request.newMeRequest( session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { TextView welcome = (TextView) findViewById(R.id.welcome); welcome.setText("Hello " + user.getFirstName() + "!"); userName = user.getName(); gender = user.asMap().get("gender").toString(); birthday = user.getBirthday(); } } }) .executeAsync(); } } }); }
public static void ui(String params, int cbIndex) { Session session = Session.getActiveSession(); if (session == null) { session = new Session(mContext); Session.setActiveSession(session); } if (session.isOpened()) { Message message = myHandler.obtainMessage(MyHandler.EXECUTE_WEBDIALOG, params); message.arg1 = cbIndex; message.sendToTarget(); } else { mStatusCallback.mCallByMode = SessionStatusCallback.CallByFBUI; mStatusCallback.mCallbackIndex = cbIndex; mStatusCallback.params = params; if (!session.isClosed()) { session.openForRead(new Session.OpenRequest(mActivity).setCallback(mStatusCallback)); } else { Session.openActiveSession(mActivity, true, mStatusCallback); } } }
/** * Updates the status of the user for the currently completed achievement. * * @param AchievementName * @param activity of your application. */ public void updateStatus(String AchievementName, final Activity activity) { mActivity = activity; final Achievement facebookInterface = new Achievement(); final Achievement_Item item = getAchievement(AchievementName); // start Facebook Login Session.openActiveSession( activity, true, new Session.StatusCallback() { public void call(final Session session, SessionState state, Exception exception) { if (session.isOpened()) { publishFeedDialog( item.getPostName(), item.getCaption(), item.getDescription(), item.getLink(), null, facebookInterface); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE); setContentView(R.layout.activity_menu); text_welcome = (TextView) findViewById(R.id.welcomeText); // Button button_question = (Button) findViewById(R.id.button_question); Button button_map = (Button) findViewById(R.id.button_map); Button button_score = (Button) findViewById(R.id.button_score); Button button_toplist = (Button) findViewById(R.id.button_toplist); Button button_exit = (Button) findViewById(R.id.button_exit); text_welcome.setText("Facebook azonosítás folyamatban..."); /*button_question.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MenuActivity.this, DisplayQuestionActivity.class); startActivity(intent); } }) button_question.setVisibility(View.INVISIBLE);*/ button_map.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MenuActivity.this, MapActivity.class); startActivity(intent); } }); button_score.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MenuActivity.this, MyScoreActivity.class); startActivity(intent); } }); button_toplist.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(MenuActivity.this, ToplistActivity.class); startActivity(intent); } }); button_exit.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { // make request to the /me API Request.executeMeRequestAsync( session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { final GraphUser guser = user; Thread t = new Thread() { public void run() { text_welcome.setText("Üdv, " + guser.getFirstName() + "!"); long userid = Long.parseLong(guser.getId()); SendIdentityUtil.sendIdentifyToServer( userid, getApplicationContext()); SharedPreferences.Editor editor = preferences.edit(); editor.putLong("faceID", userid); editor.commit(); } }; t.run(); } } }); } } }); }
private void getOpenedSession() { Session.openActiveSession(this, true, statusCallback); }
public static void login(int cbIndex, String scope) { Log.i(TAG, "dsafsdfas"); Session session = Session.getActiveSession(); if (session == null) { session = new Session(mContext); Session.setActiveSession(session); } String[] permissions = null; mNeedPublishPermissions = false; if (scope != null) { permissions = scope.split(","); for (int i = 0; i < permissions.length; i++) { if (allPublishPermissions.contains(permissions[i])) { mNeedPublishPermissions = true; break; } } } if (session.isOpened()) { Log.i(TAG, "openActiveSession2"); if (scope == null || session.getPermissions().containsAll(Arrays.asList(permissions))) { Log.e(TAG, "FB.login() called when user is already connected."); } else { mStatusCallback.mCallByMode = SessionStatusCallback.CallByLogin; mStatusCallback.mCallbackIndex = cbIndex; if (mNeedPublishPermissions) { session.requestNewPublishPermissions( new Session.NewPermissionsRequest(mActivity, Arrays.asList(permissions))); } else { session.requestNewReadPermissions( new Session.NewPermissionsRequest(mActivity, Arrays.asList(permissions))); } } } else { mStatusCallback.mCallByMode = SessionStatusCallback.CallByLogin; mStatusCallback.mCallbackIndex = cbIndex; Log.i(TAG, "openActiveSession1"); if (!session.isClosed()) { mOpenRequest = new Session.OpenRequest(mActivity); if (permissions != null) mOpenRequest.setPermissions(Arrays.asList(permissions)); mOpenRequest.setCallback(mStatusCallback); if (mNeedPublishPermissions) { Log.i(TAG, "openActiveSession4"); session.openForPublish(mOpenRequest); } else { Log.i(TAG, "openActiveSession5"); session.openForRead(mOpenRequest); } } else { Log.i(TAG, "openActiveSession"); Session.openActiveSession(mActivity, true, mStatusCallback); } } /* * Session session = Session.getActiveSession(); if (!session.isOpened() * && !session.isClosed()) { session.openForRead(new * Session.OpenRequest(mActivity) * .setPermissions(Arrays.asList("basic_info")).setCallback( * mStatusCallback)); } else { Session.openActiveSession(mActivity, * true, mStatusCallback); } */ }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*取得螢幕寬高*/ DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); /*Activity永不休眠*/ getWindow() .setFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); ScreenWidth = dm.widthPixels; ScreenHeight = dm.heightPixels; /*取得系統時間*/ /*檔案格式系統時間*/ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.TAIWAN); files = dateFormat.format(new java.util.Date()); /*資料格式系統時間*/ SimpleDateFormat logdateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.TAIWAN); s = logdateFormat.format(new java.util.Date()); /*初始化SoundPool物件*/ sound = new SoundPool(7, AudioManager.STREAM_MUSIC, 5); BlowFail = sound.load(this, R.raw.blowfail, 0); Blowing = sound.load(this, R.raw.blowing, 0); BlowDone = sound.load(this, R.raw.testdone, 0); ShowBacValue = sound.load(this, R.raw.showbacvalue, 0); WaitBacZero = sound.load(this, R.raw.waitbastozero, 0); StartBlow = sound.load(this, R.raw.rdytest, 0); FailConnect = sound.load(this, R.raw.failconnect, 0); Alarm = sound.load(this, R.raw.alarm, 0); /*系統等待一秒 Loading SoundPool*/ SystemClock.sleep(1000); location = locationServiceInitial(); Prefs = new Preference(); /*初始化藍芽接口*/ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); /*若藍牙沒開,強制開啟藍牙*/ if (!mBluetoothAdapter.isEnabled()) { mBluetoothAdapter.enable(); SystemClock.sleep(2000); } /*建立資料夾目錄*/ CreateDir(); /*判斷是否有網路連線*/ if (haveInternet()) { Session.openActiveSession( this, true, new Session.StatusCallback() { // callback when session changes state @SuppressWarnings("deprecation") @Override public void call(final Session session, SessionState state, Exception exception) { System.out.println(state.toString() + "/state"); if (session.isOpened()) { // make request to the /me API Request.executeMeRequestAsync( session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { // TODO Auto-generated method stub if (user != null) { System.out.println("Hello " + user.getName() + "!"); UserName = user.getName(); } } }); } } }); /*判斷是否已輸入發送酒測超標簡訊號碼*/ /*File phonenumber = new File(Msgphonepath+"/PhoneNumber.txt"); if(phonenumber.exists()) SendSmsNum=GetSendSmsNum(); */ if (Prefs.GetPrefs(MainActivity.this) == "") { System.out.println("nophonenum" + Prefs.GetPrefs(MainActivity.this)); } else SendSmsNum = GetSendSmsNum(); } else { NoInternetDialog(); } }