小编r3d*_*m4n的帖子

Android设计支持库有哪些新功能以及如何使用其Snackbar?

面向开发人员的Android M Preview昨天发布.像往常一样,引入了许多令人惊叹的新功能.我注意到这Snackbar是其中之一.

我已经阅读了文档Snackbar,从中我了解到Snackbar位于Android设计支持库的库中,其绝对路径是android.support.design.widget.Snackbar.

该文件说:

Snackbars提供有关操作的轻量级反馈.它们在移动屏幕底部显示简短消息,在较大设备上显示左下方.Snackbars出现在屏幕上的所有其他元素上方,一次只能显示一个.

它们会在超时后或屏幕上其他位置的用户交互后自动消失,尤其是在召唤新表面或活动的交互之后.Snackbars可以在屏幕上刷掉.

那么,Snackbar表现得像一个Toast或一个Dialog?可以在布局文件中使用Snackbars吗?我怎么能以编程方式使用它?

PS:

  • 任何使用Snackbar的样品都将受到赞赏.
  • Android设计支持库是一个新的支持库,有人可以向我展示这个库的更多细节吗?

android android-support-library material-design android-design-library android-snackbar

34
推荐指数
3
解决办法
2万
查看次数

使用Facebook登录集成的Firebase Auth用户的空电子邮件字段(Firebase 3.0)

我已成功部署了https://firebase.google.com/docs/auth/android/facebook-login中的教程代码,以便将Firebase身份验证登录与Facebook集成.用户已在Firebase Auth控制台中成功创建.

但是,我注意到用户对象中的电子邮件字段为空( - ).奇怪的是,我使用获取的令牌使用GraphRequest直接从提供者结果对象中成功检索了电子邮件信息.

根据我阅读的文档(https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser.html#getEmail()),应从登录提供商填充电子邮件字段.

一些额外的奇怪行为:

  1. 成功登录后,将调用onAuthStateChanged两次.firebaseAuth.getCurrentUser().getProviderId()的值在两种情况下都是Firebase
  2. 我尝试从FirebaseUser对象user.getProviderData()列出提供程序.我有两个提供商:firebase和facebook.com
  3. 当我尝试使用FirebaseUser.updateEmail(event.getEmail())更新电子邮件时,我收到此错误:发生了内部错误.[EMAIL_EXISTS]

有什么我想念或做的我做错了吗?

这是我的代码:

public class LoginActivity extends AppCompatActivity {
    private static final String TAG = "LOGIN_ACTIVITY";
    private static final int RC_SIGN_IN = 777;
    private EventBus eventBus;
    private SweetAlertDialog pDialog;

    private FirebaseAuth mAuth;
    private FirebaseAuth.AuthStateListener mAuthListener;
    private CallbackManager mCallbackManager;
    private ImageView mPasswordVisibilityView;
    private TextView txtPassword;
    private boolean justEnteredAuthStateChanged = false;
    private GoogleApiClient mGoogleApiClient;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getApplicationContext());

        setContentView(R.layout.login);

        // Firebase
        mAuth = FirebaseAuth.getInstance();

        mAuthListener …
Run Code Online (Sandbox Code Playgroud)

android facebook-authentication firebase firebase-authentication

20
推荐指数
4
解决办法
1万
查看次数

带有工具栏和TabLayout的ViewPager高度错误

我在AppBarLayout下面有一个ViewPager(带有工具栏和TabLayout).我无法理解为什么加载的片段的高度超过可用空间,即使没有这么大的元素,使标签可滚动.

这是主要的布局xml:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill"
            app:tabMode="fixed" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

正如你在我的片段中看到的那样,我有一个带有layout_alignParentBottom的Button,但我猜它会拉伸viewpager的高度太多.

截图

这里是设计视图的布局:

在此输入图像描述

android android-viewpager android-toolbar android-tablayout

14
推荐指数
2
解决办法
5769
查看次数

Firebase Android身份验证失败:expired_token(身份验证令牌已过期)

我遇到Android Firebase Auth使用com.google.gms:google-services:3.0.0和的问题com.google.firebase:firebase-auth:9.0.1.

使用Firebase(Google或Facebook)验证后1小时,我收到以下错误消息:

W/PersistentConnection: pc_0 - Authentication failed: expired_token (Auth token is expired)

为什么Firebase令牌在1小时后过期以及如何延长此有效期?

UPDATE

我仍然遇到此问题,Firebase令牌在1小时后过期.现在我收到以下消息: W/PersistentConnection: pc_0 - Authentication failed: invalid_token (Invalid claim 'kid' in auth header.)

我感谢任何帮助.

android google-authentication facebook-authentication firebase-authentication

13
推荐指数
1
解决办法
1万
查看次数

Expo SDK 48 破坏了 Firebase Auth

我刚刚升级到 Expo SDK 48,似乎每次刷新后我都会注销。我降级回 SDK 47,一切都按预期工作。我使用的是 firebase v9 (v9.17.1),是通过 expo install 安装的,而不是通过纱线安装的。

我升级到 Expo 48 时遵循的步骤:

  • 更新到最新版本的 EAS CLI:npm i -g eas-cli。
  • 安装新版本的Expo包:yarn add expo@^48.0.0
  • 升级所有依赖项以匹配 SDK 48:npx expo install --fix
  • 检查项目依赖项中是否存在任何可能的问题:npx expo-doctor
  • 升级到最新版本的firebase web sdk:expo install firebase
  • 删除节点模块,yarn.lock并重新安装所有内容

我缺少什么?

我在发行说明中找不到任何可以帮助我的内容。

firebase react-native firebase-authentication expo

10
推荐指数
1
解决办法
1967
查看次数

嵌套的操作栏选项卡(使用ViewPager)

我有一个使用Action Bar Tabs(使用ViewPager)的项目.在它们之间滑动时,标签移动非常顺畅,但我需要在TAB 2中添加两个子标签,然后移动到下一个标签或当然返回,就像在Glassdoor或Flipboard上一样.

请帮忙.

玻璃门 我的应用程序

主要活动

public class MainActivity extends AppCompatActivity {


private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

}


public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {

            switch (position) {
                case 0:
                    return Tab1Fragment.newInstance();
                case 1:
                    return Tab2Fragment.newInstance();
                default:
                    return Tab3Fragment.newInstance(); …
Run Code Online (Sandbox Code Playgroud)

android android-viewpager android-tabs android-studio android-tabbed-activity

9
推荐指数
1
解决办法
4098
查看次数

登出时Firebase facebook按钮android身份验证

我在我的Android应用程序和facebook SDK中使用firebase也用于登录.我面临的唯一问题是,当我登录facebook,然后注销时,facebook登录按钮处于"注销"状态,当我点击它时,它会询问我是否要注销.

如图所示

问题ScreenShot

我要做的是注销:

FirebaseAuth.getInstance().signOut()
Run Code Online (Sandbox Code Playgroud)

所以,这显然只清除我在firebase上的会话,但不会断开我的应用程序与Facebook,该怎么办?

android facebook-authentication firebase

7
推荐指数
1
解决办法
1515
查看次数

新的Firebase Facebook登录

我正在尝试使用新的Firebase平台进行Facebook登录.

这是facebook登录的代码

let facebookLogin = FBSDKLoginManager()
    facebookLogin.logInWithReadPermissions(["email"], fromViewController: self) { (result, error) -> Void in
        if error != nil {
            print("error is \(error)")
        } else {
            let accessToken = FBSDKAccessToken.currentAccessToken().tokenString

            let credential = FIRFacebookAuthProvider.credentialWithAccessToken(accessToken)

            AUTH?.signInWithCredential(credential, completion: { (user, error) -> Void in

                if error != nil {
                    print("error is \(error)")
                } else {
                    print(user)
                    NSUserDefaults.standardUserDefaults().setValue(user?.uid, forKey: KEY_UID)
                    self.performSegueWithIdentifier(SEGUE_LOGGEDIN, sender: nil)
                }
            })
        }
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误代码

可选(错误域= FIRAuthErrorDomain代码= 17999"发生内部错误,打印并检查错误详细信息以获取更多信息."UserInfo = {error_name = ERROR_INTERNAL_ERROR,NSUnderlyingError = 0x79f082b0 {Error Domain = FIRAuthInternalErrorDomain Code = 3"(null)" …

facebook-authentication firebase firebase-authentication swift2

6
推荐指数
1
解决办法
1695
查看次数

通过Facebook和Google进行的Firebase Auth与隐私权政策有什么关系?

我想使用Firebase Realtime Database将简单的数据库后端开发到我的Android应用程序。我想通过Firebase Auth(Facebook和Google)对用户进行身份验证。我需要写隐私政策吗?我想答案是肯定的,因此是否有任何预制的隐私政策(我仅存储此Auth系统提供的信息:displayName,email,imgUri)?

android google-authentication facebook-authentication firebase-authentication privacy-policy

5
推荐指数
0
解决办法
248
查看次数

Android Firebase Google SIgnon请求不好

Android Firebase Google在google返回令牌ID时签署授权错误.我有两个cleint id以及在firebase上保存的web sdk密钥.甚至json文件.

 AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                        // If sign in fails, display a message to the user. If sign in succeeds
                        // the auth state listener will be notified and logic to handle the
                        // signed in user can be handled in the listener.
                        if (!task.isSuccessful()) {
                            Log.w(TAG, "signInWithCredential", task.getException());
                            Toast.makeText(OnBoarding.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                        // ...
                    }
                });
Run Code Online (Sandbox Code Playgroud)

得到了这个错误 …

android google-authentication firebase firebase-authentication

4
推荐指数
1
解决办法
2602
查看次数