android - 当我运行我的项目/
问题描述
我有一个包含 API 密钥的文件,但我不断收到此错误。当我知道所有内容都正确命名并且我有一个 API 密钥时,我想不出任何理由为什么会收到一个无效的 API 密钥错误。这是我的 mainactivity.java 文件中的代码。我认为我设置图像按钮的方式可能存在问题,但我不确定并且非常困惑。任何帮助将不胜感激。
这是我在运行应用程序的模拟器上单击按钮时不断遇到的实际错误。
public class MainActivity extends AppCompatActivity {
private RequestContext requestContext;
ImageButton loginButton;
@Override
protected void onResume() {
super.onResume();
requestContext.onResume();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/* Previous onCreate declarations omitted */
// Find the button with the login_with_amazon ID
// and set up a click handler
//loginButton = findViewById(R.id.login_with_amazon);
loginButton = (ImageButton) findViewById(R.id.login_with_amazon);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Toast.makeText(MainActivity.this, "it works", Toast.LENGTH_LONG).show();
AuthorizationManager.authorize(new AuthorizeRequest
.Builder(requestContext)
.addScopes(ProfileScope.profile(), ProfileScope.postalCode())
.build());
}
});
requestContext = RequestContext.create(this);
requestContext.registerListener(new AuthorizeListener() {
/* Authorization was completed successfully. */
@Override
public void onSuccess(AuthorizeResult result) {
/* Your app is now authorized for the requested scopes */
}
/* There was an error during the attempt to authorize the
application. */
@Override
public void onError(AuthError ae) {
/* Inform the user of the error */
}
/* Authorization was cancelled before it could be completed. */
@Override
public void onCancel(AuthCancellation cancellation) {
/* Reset the UI to a ready-to-login state */
}
});
}
}
解决方案
推荐阅读
- amazon-web-services - 如何为任务提供不同环境变量 ECS Terraform
- java - 如何从 CSV 中获取一个值,将其递增并使用 java 将其保存回来
- git - “git update-index --skip-worktree”突然不再工作
- javascript - 如何动态访问对象然后编辑其内容
- git - 提交没有在与 gitlab api 的合并请求中提交
- android - RecyclerView 中的分隔线在展开和折叠项目时表现异常
- python - Iterate and replace values through a numpy array Python
- flutter - Flutter 应用程序在使用睡眠功能时卡住了
- git - git如何删除服务器上的远程引用
- python - 在 Python 中为二十一点游戏从一副牌中绘制独特的牌