当我尝试通过 google 登录时,出现此异常
2020-11-12 13:32:51.571 7351-7351/com.test.app W/aaab: com.google.android.gms.common.api.ApiException: 8
这是什么意思?
代码
public class MainActivity extends AppCompatActivity {
private GoogleSignInClient mGoogleSignInClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleSignInClient = GoogleSignIn.getClient(this, new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build());
Button btnSignIn = (Button) findViewById(R.id.btn_sign_in);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(mGoogleSignInClient.getSignInIntent(), 100);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
if (task.isSuccessful()) {
Toast.makeText(this, "Done", …Run Code Online (Sandbox Code Playgroud) 我尝试通过 URL 在视频中显示字幕,但它告诉我需要登录
我的尝试
结果是需要登录
来源
https://material.io/develop/android/components/buttons#text-button
从这个参考文献中有一个 setIcon 方法,但我如何才能到达它?

这是一个人为的例子。我有一个非 void 方法,它抛出异常。为什么我之后不需要返回一个值?毕竟,该方法是非无效的。
public static Toast makeText(Context context, CharSequence text, int duration) {
throw new RuntimeException("Stub!");
//Must return something from here but there is not, Why?
}
Run Code Online (Sandbox Code Playgroud) 为什么 RecyclerView 适配器不能与 ButterKnife 一起使用?
它适用于 findViewById 但不适用于 ButterKnife
适配器类
public class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.viewHolder>{
Context context;
List<CategoriesModels> categoriesModels;
public CategoriesAdapter(Context context,List<CategoriesModels> categoriesModels){
this.context = context;
this.categoriesModels = categoriesModels;
}
@Override
public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_categories, viewGroup, false);
viewHolder viewHolder = new viewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull viewHolder viewHolder, int i) {
}
@Override
public int getItemCount() {
return categoriesModels.size();
}
class viewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.img_flag)
ImageView img_flag;
@BindView(R.id.txt_title) …Run Code Online (Sandbox Code Playgroud) android adapter android-studio butterknife android-recyclerview
我试图为按钮提供一个图标,但它看起来像这样!
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Button"
app:icon="@drawable/ic_facebook"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我试图在互联网上找到相关问题,但不幸的是找不到与此问题相关的任何内容,或者我搜索得不够
android android-button material-design material-components-android
我在 firestore 中的文档中有数组,这个数组大约有 284 个项目,有没有办法获取数组长度?
我没有任何相关代码,但您可以留下简单的示例或方法名称,谢谢。
我的应用程序仅支持使用 Firebase 身份验证通过电子邮件/密码、Google 和 Facebook 登录。
在里面Authentication -> Settings tab,Firebase 对我说"Upgrade to Firebase Auth with Identity platform to access this feature."
我升级成功是因为我想禁用在客户端创建新帐户并禁用删除帐户。这些功能只是我想要的。
如果您有兴趣知道为什么我要禁止在客户端创建新帐户?请在这里检查我的问题以了解原因。
今天我打开Firebase Pricing,发现 Firebase 身份验证发生了变化,如您所见,Firebase 在最后添加了 2 行新行。
我没有在电话验证中付费,因为我不使用该提供商。我只收取 Firebase 实时数据库和 Firebase 存储的费用。
这是我的问题:
Identity Platform Pricing Monthly active users (excluding SAML/OIDC)=> 如果每日活跃用户数为 83,000 (83,000 * 30 = 2,490,000),到月底我大约需要支付多少费用?Monthly active users - SAML/OIDC=> 正如我上面所说,我的应用程序仅支持通过电子邮件/密码、Google 和 Facebook 登录,这是否意味着我不会因 SAML 和 OIDC 付费?我希望一切都清楚。谢谢。
firebase google-cloud-platform google-identity-toolkit firebase-authentication
我 1 天前尝试登录 Google Play 游戏,但从来没有登录过,除非我收到以下消息。
日志猫
I/salahtaha: com.google.android.gms.common.api.ApiException: 4: 4:
Run Code Online (Sandbox Code Playgroud)
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.salah250.test.test">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
Java代码
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private void signInSilently() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
signInClient.silentSignIn().addOnCompleteListener(this,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
GoogleSignInAccount …Run Code Online (Sandbox Code Playgroud) 我正在尝试更改顶部栏的背景颜色并使其像主背景一样。我正在使用Material You (MD3)。
用户可以从浅色模式更改为深色模式,反之亦然。
这是我尝试做的:
值\主题.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App" parent="Theme.Material3.Light.NoActionBar">
<item name="android:colorBackground">@color/md_theme_light_background</item>
...
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
值夜\themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App" parent="Theme.Material3.Dark.NoActionBar">
<item name="android:colorBackground">@color/md_theme_dark_background</item>
...
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
颜色.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="md_theme_light_background">#FCFDF7</color>
<color name="md_theme_dark_background">#1A1C19</color>
...
</resources>
Run Code Online (Sandbox Code Playgroud)
活动主文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".activities.MainActivity">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?android:attr/colorBackground"
android:elevation="4dp"
app:title="@string/app_name" />
...
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
结果(深色模式)
正如你所看到的,顶部栏的背景颜色一定是,#1A1C19但它变成了#222E22,从哪里来的#222E22?
我试图在 MD3 文档中找到任何有关此内容的内容,但没有找到任何内容。你能告诉我为什么颜色会自动改变吗?
注意:如果我
md_theme_dark_background从 …
android material-design android-toolbar material-components-android
如何使用contains方法仅按 id 进行搜索,我想在不使用循环的情况下检查 id 是否等于 4,如何?
测试班
public class Test {
private int id;
private String name;
private int age;
public Test(int id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
}
Run Code Online (Sandbox Code Playgroud)
设置数据
List <Test> list = new ArrayList <> ();
list.add(new Test(1, "Name 1", 25));
list.add(new Test(2, "Name 2", 37));
list.add(new Test(3, "Name 3", 63));
list.add(new Test(4, "Name 4", 19));
list.add(new Test(5, "Name 5", 56));
Run Code Online (Sandbox Code Playgroud) 错误信息:
C:\FWE\Android\app\build\generated\data_binding_base_class_source_out\debug\out\com\test\app\databinding\RowCategoryBinding.java:14: error: cannot find symbol
import com.test.app.Models;
symbol: class Models
location: package com.test.app
Run Code Online (Sandbox Code Playgroud)
关于RowCategoryBinding.java:14,它包含这个
import com.test.app.Models;
Run Code Online (Sandbox Code Playgroud)
CategoriesModel.java如果我将文件放入 Models 文件夹中,则会出现错误
com.test.app
|
--- Adapters
--- Activites
--- Fragments
--- Models
|
--- CategoriesModel.java
--- Interfaces
--- Utils
--- ViewModels
Run Code Online (Sandbox Code Playgroud)
但是,如果我将CategoriesModel.java文件移到模型之外,那么该应用程序将正常运行而不会出现错误。是什么原因?
com.test.app
|
--- Adapters
--- Activites
--- Fragments
--- Models
--- Interfaces
--- Utils
--- ViewModels
--- CategoriesModel.java
Run Code Online (Sandbox Code Playgroud) 我的应用程序从NewAdFragment这个片段开始,里面有一个按钮,允许用户选择类别,当用户单击该按钮时,我将通过ChooserFragment传递类别列表作为参数将他导航到,这个片段中有 RecyclerView ,它显示类别。
我想要什么?我希望当用户从 RecyclerView 中选择一个项目时,它必须返回NewAdFragment特定的数据。
我可以用很多方法解决这个问题,但也许导航组件库中已经存在一种方法。
最好的方法是什么?
android ×9
google-api ×2
java ×2
material-components-android ×2
adapter ×1
android-architecture-navigation ×1
butterknife ×1
button ×1
exception ×1
firebase ×1
google-oauth ×1
oauth ×1
return ×1
youtube-api ×1