- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
当应用程序在手机 HUAWEI ALE - 21 Android 6.0 API 23 上运行时,我正在努力解决这个问题。我的应用程序崩溃了,我收回了那些错误。
java.lang.SecurityException: Permission Denial: 需要 com.huawei.android.launcher.permission.WRITE_SETTINGS
W/DynamiteModule:找不到 com.google.firebase.auth 的本地模块描述符类。
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.efti.myapplication">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL"/>
<uses-permission android:name="com.android.voicemail.permission.WRITE_VOICEMAIL"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="com.android.voicemail.permission.READ_VOICEMAIL"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE"
tools:ignore="ProtectedPermissions" />
<!-- We use this to disable the status bar buttons of home, back and recent
during an incoming call. By doing so this allows us to not show the user
is viewing the activity in full screen alert, on a fresh system/factory
reset state of the app. -->
<uses-permission android:name="android.permission.STATUS_BAR"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.CAMERA"/>
<!-- This tells the activity manager to not delay any of our activity
start requests, even if they happen immediately after the user
presses home. -->
<uses-permission android:name="android.permission.STOP_APP_SWITCHES"
tools:ignore="ProtectedPermissions" />
<!-- Permissions needed for badger count showing on launch icon. -->
<!--for Samsung-->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<!--for htc-->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<!--for sony-->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<!--for apex-->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<!--for solid-->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<!--for huawei-->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
<!--for ZUK-->
<uses-permission android:name="android.permission.READ_APP_BADGE"/>
<!--for OPPO-->
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<application
android:allowBackup="true"
android:icon="@drawable/common_google_signin_btn_icon_light"
android:label=""
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
android:supportsRtl="true">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home"
android:theme="@style/AppTheme.NoActionBar"/>
</application>
</manifest>
登录 Activity .java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import java.util.Arrays;
public class LoginActivity extends AppCompatActivity {
private EditText inputEmail, inputPassword;
private FirebaseAuth auth;
private ProgressBar progressBar;
private Button btnSignup, btnLogin, btnReset;
private static final String EMAIL = "email";
private CallbackManager callbackManager;
private LoginButton loginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList(EMAIL));
// If you are using in a fragment, call loginButton.setFragment(this);
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
AccessToken accessToken = AccessToken.getCurrentAccessToken();
boolean isLoggedIn = accessToken != null && !accessToken.isExpired();
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile"));
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
}
// set the view now
setContentView(R.layout.activity_login);
inputEmail = (EditText) findViewById(R.id.email);
inputPassword = (EditText) findViewById(R.id.password);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
btnSignup = (Button) findViewById(R.id.btn_signup);
btnLogin = (Button) findViewById(R.id.btn_login);
btnReset = (Button) findViewById(R.id.btn_reset_password);
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
btnSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this, SignupActivity.class));
}
});
btnReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this, ResetPasswordActivity.class));
}
});
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();
if (TextUtils.isEmpty(email)) {
Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show();
return;
}
progressBar.setVisibility(View.VISIBLE);
//authenticate user
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// 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.
progressBar.setVisibility(View.GONE);
if (!task.isSuccessful()) {
// there was an error
if (password.length() < 6) {
inputPassword.setError(getString(R.string.minimum_password));
} else {
Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
}
} else {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
});
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
}
最佳答案
您需要检查权限并请求权限,如下所示:
代码示例:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
"com.huawei.android.launcher.permission.WRITE_SETTINGS")
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
"com.huawei.android.launcher.permission.WRITE_SETTINGS")) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(thisActivity,
new String[]{"com.huawei.android.launcher.permission.WRITE_SETTINGS"},
MY_PERMISSIONS_REQUEST_WRITE_SETTINGS);
// MY_PERMISSIONS_REQUEST_WRITE_SETTINGS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
} else {
// Permission has already been granted
}
有关详细信息,请参阅:https://developer.android.com/training/permissions/requesting
关于java.lang.SecurityException : Permission Denial: requires com. huawei.android.launcher.permission.WRITE_SETTINGS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53952683/
使用 ABC 加载模块 ( require )在分发的一个模块中工作,而在分发的另一个模块中失败。 加载 ABC 的原因可能是什么?与 require在一个地方失败? require Name::AB
我定义了以下方法: void Write(string fileContent, string fileName, string container = StorageBlobContainers.P
现在,Require.js是我最喜欢的Javascript编程方式。它可以使代码化整为零,并易于管理。而Require.js Optimizer能帮助我们将一个较大的应用分散成多个较小的应用,并通过
尝试开始使用 apioto http://apiato.io/A.getting-started/installation/ 如果我尝试测试 http://api.apiato.dev/registe
浏览 MDN 文档以查看提议的伪类的状态时,我遇到了 :required(并且扩展为 :optional)。这两个都已经存在很长时间了,但我现在才刚刚了解到。 此选择器与使用属性选择器 [requir
我正在尝试实现此条件:如果存在特定属性,则需要另一个属性;但如果它不存在,则不需要另一个。 另外,在 JSON 模式中,我们可以在依赖项中使用 not 吗? 这是一个示例架构 var schema =
我正在使用react-hot-loader我对其示例代码感到非常困惑: import React from 'react' import ReactDOM from 'react-dom' impor
过去几天我一直在玩 requirejs。我试图理解定义和要求之间的区别。 Define 似乎允许模块分离并允许遵守依赖关系顺序。但它会下载开始时所需的所有文件。而 require 仅在您需要时加载您需
我的项目是使用 angular cli [版本 - 6.1.3] 创建的。 我安装了 npm 模块 - is-reachable并在我的代码中使用它作为 - const isReachable = r
(有人可能会相应地更改标题)当像这样调用 javascript 的 require 方法时到底发生了什么: var xyz = require('xy')(require('z')); 谢谢 最佳答案
我一直在使用编译为 Node 代码的 Typescript 开发应用程序。因此,我更喜欢使用 import 语句来 require。 我一直在尝试将 Lodash 与 Lodash-Deep 一起使用
我在 require 中有一个奇怪的行为,我不知道如何避免(或者也许我的基础知识错误?)。 考虑以下代码: define (require) -> potoo = require "potoo"
这两种加杏仁和不加杏仁有什么区别? require('模块');require(['模块']); 编辑 嵌套: define(function() { require('module'); } def
我愿意使用 require.js 优化器优化我的 javascript 应用程序,但我现在想知道是否也可以在一个文件中包含 require.config 路径和 javascript 模块。事实上,在
我想我需要在一个页面中支持多个 require 实例,但在实现它时遇到了两个问题。我正在开发一项服务,该服务向外部客户端页面提供可嵌入的交互式对象。最重要的设计标准是易于嵌入,尽可能少地假设客户端环境
required 和 ng-required(表单验证)之间有什么区别? 最佳答案 AngularJS 表单元素查找 required属性来执行验证功能。 ng-required允许您设置requir
我有以下多选框: 0" /> 在我的 Controller 中,我在初始化时执行此操作: $scope.form.Slides = []; 如果幻灯片数组中有幻灯片,我希望表单的此元素有效。这些是动
我在 ubuntu 上运行 VPS: Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 C
我正在使用 ArcGIS API for Javascript 3.21。我在 require() 中有一个函数。我希望在单击按钮时调用该函数,但该按钮位于 require() 之外。
我的浏览器应用程序使用 require.js。该应用程序在屏幕上显示许多不同的小部件之一。 URL 片段包含小部件的路径(require.js 路径),然后调用 require 来动态加载它: var
我是一名优秀的程序员,十分优秀!