- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在将 Google Plus 集成到我的 Android 应用程序中。我已经在 Google API 控制台中创建了该项目。我创建了 OAuth 客户端 ID,并仔细检查了包名称和 keystore SHA1,但两者都是正确的,但我仍然收到 Internal Error Occur
。
我看过很多帖子,但主要是说与 SHA1 和包名称相关的内容,这里是正确的。
大家分享您的观点。
编辑:我已经使用 debug.keystore 和自定义创建的 keystore 进行了测试,但对我没有任何作用。
setScopes("PLUS_LOGIN")
对我也没有帮助。
public class MainActivity extends Activity implements ConnectionCallbacks,
OnConnectionFailedListener, OnClickListener {
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
private static final String TAG = "Google Plus Demo";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPlusClient = new PlusClient.Builder(this, this, this)
.setActions("http://schemas.google.com/AddActivity",
"http://schemas.google.com/BuyActivity")
.setScopes(Scopes.PLUS_LOGIN).build();
// Progress Bar to be displayed if the connection failure is not
// resolved.
mConnectionProgressDialog = new ProgressDialog(this);
mConnectionProgressDialog.setMessage("Signing in...");
findViewById(R.id.sign_in_button).setOnClickListener(this);
}
@Override
protected void onStart() {
super.onStart();
mPlusClient.connect();
}
@Override
protected void onStop() {
super.onStop();
mPlusClient.disconnect();
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if(requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if(mConnectionProgressDialog.isShowing()) {
// The user clicked on the sign-in button already. Start to resolve
// connection errors. Wait until onConnected() to dismiss the
// connection dialog.
if(result.hasResolution()) {
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch(SendIntentException e) {
mPlusClient.connect();
}
}
}
// Save the result
mConnectionResult = result;
}
@Override
public void onConnected(Bundle connectionHint) {
String accountName = mPlusClient.getAccountName();
Toast.makeText(this, accountName, Toast.LENGTH_LONG).show();
mConnectionProgressDialog.dismiss();
}
@Override
public void onDisconnected() {
Log.d(TAG, "Disconnected");
}
@Override
public void onClick(View view) {
if(view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
if(mConnectionResult == null) {
mConnectionProgressDialog.show();
} else {
try {
mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch(SendIntentException e) {
// Try connecting again
mConnectionResult = null;
mPlusClient.connect();
}
}
}
}
}
日志
01-27 20:22:23.871: I/GLSUser(1699): GLS error: INVALID_SCOPE xyz@gmail.com oauth2:PLUS_LOGIN
01-27 20:22:23.871: W/GLSActivity(1699): [aia] Status from wire: INVALID_SCOPE status: INVALID_SCOPE
01-27 20:22:23.965: W/InputManagerService(1536): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4076b580
01-27 20:22:24.020: I/eFrame(3180): pkgname_before:com.google.android.gms class:com.xicom.appdemo.MainActivity
01-27 20:22:24.027: D/SurfaceFlinger(1536): Layer[34bee8]:: Tile format buffer w[256] h[64] f[1] v[0x47855000] p[0x97fd5000] sz[65536]
01-27 20:22:25.012: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0
01-27 20:22:25.012: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause
01-27 20:22:25.106: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep
01-27 20:22:27.684: W/PowerManagerService(1536): Timer 0x3->0x3|0x3
01-27 20:22:27.691: D/BatteryService(1536): update start
代码:
mPlusClient = new PlusClient.Builder(this, this, this)
.setActions("http://schemas.google.com/AddActivity",
"http://schemas.google.com/BuyActivity")
.build();
记录第二个版本
01-28 22:25:16.164: D/SurfaceFlinger(1536): Layer[37c9c0]:: Tile format buffer w[256] h[320] f[1] v[0x4ac99000] p[0x94741000] sz[327680]
01-28 22:25:17.007: D/SurfaceFlinger(1536): Layer[8a5a68] [4] non-RGB565 reloads
01-28 22:25:17.250: I/fno(2652): I/O exception (javax.net.ssl.SSLException) caught when processing request: Write error: ssl=0x25d728: I/O error during system call, Broken pipe
01-28 22:25:17.250: I/fno(2652): Retrying request
01-28 22:25:18.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads
01-28 22:25:18.101: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0
01-28 22:25:18.101: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause
01-28 22:25:18.187: D/BatteryService(1536): update start
01-28 22:25:18.195: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep
01-28 22:25:19.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null
01-28 22:25:19.484: I/GLSUser(2652): GLS error: INVALID_CLIENT_ID xyz@gmail.com oauth2:https://www.googleapis.com/auth/plus.login
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: Unknown status: UNKNOWN
01-28 22:25:19.570: D/dalvikvm(20673): GC_EXTERNAL_ALLOC freed 163K, 43% free 3397K/5959K, external 511K/517K, paused 47ms
01-28 22:25:19.664: W/InputManagerService(1536): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40605c00
01-28 22:25:19.781: D/SurfaceFlinger(1536): Layer[278dc0]:: Tile format buffer w[256] h[64] f[1] v[0x49520000] p[0x97fcc000] sz[65536]
01-28 22:25:19.835: I/eFrame(20257): pkgname_before:com.google.android.gms class:com.xicom.appdemo.MainActivity
01-28 22:25:20.046: D/dalvikvm(20257): GC_CONCURRENT freed 384K, 49% free 3021K/5895K, external 412K/517K, paused 4ms+6ms
01-28 22:25:20.757: W/PowerManagerService(1536): Timer 0x3->0x3|0x3
01-28 22:25:23.203: D/BatteryService(1536): update start
最佳答案
我遇到了同样的问题,我在 Developer Console 中四处查看解决了它。
事实证明,您需要为同意屏幕填写有关您的项目的必要信息。
解决方法:
选择您的电子邮件并插入您的项目名称。下次启动您的应用程序时,您将看到适当的同意屏幕,此后一切都会正常工作。
关于android - toast : Internal Error Occur with integration of Google Plus in Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21361463/
这个问题在这里已经有了答案: How to prevent Multiple Toast Overlaps (8 个答案) 关闭 6 年前。 我有很多按钮。点击它们中的每一个,我都会显示一个 toa
我想为 Windows Phone 8.1 开发一个包含本地“通知”的通用应用程序。 我想要做的是在 toast 控件的扭结中向用户显示所有消息(错误、信息、警告)。 一切都在本地完成,无需通过标准通
有没有办法在 ionic 2 toast 中设置文本消息的样式? 我试过这个: let toast = Toast.create({ message: "Some text on
我有一个附加到按钮的函数,按下该按钮将从数组列表中删除一个项目,然后显示一个提示“项目已删除!”。如果我多次按下删除按钮,那么所有的 toast 都会显示出来,使其看起来像一个非常长的 toast 显
我在这里读到过此类问题,但答案似乎不起作用。 当用户点击按钮时,我会显示一个Toast。当用户连续点击按钮时,即使用户退出 Activity ,toast 也会一次又一次地显示。 toast 的长度很
我有几个可以在 fragment 上单击的按钮。单击每个按钮后,我会显示一条 Toast 消息,每个按钮都完全相同。因此,如果你一个接一个地按下 5 个不同的按钮,你将叠加 5 个 toast 消息,
我有几个 SeekBar 和 onSeekBarProgressStop(),我想显示一个 Toast 消息。 但是,如果在 SeekBar 上我快速执行操作,那么 UI 线程会以某种方式阻塞并且 T
有没有办法在 android 中获取与特定 android Toast 对象关联的消息? toast=Toast.makeText(getAppContext(), message, Toast.LE
我正在创建我的自定义 toast,主要是因为我将它放在 GridView 上并且需要对其宽度进行一些控制。但我真的很喜欢标准 toast 上的淡蓝色光环,并希望恢复它(或者至少让我的自定义 toast
我正在使用 Espresso 测试一个应用程序。我有一个问题,是否可以等到当前没有 toast 显示。我的应用程序中有很多不同的 toast,但是在测试时我遇到了问题,因为据我所知,焦点已经转移到 t
这可能是一个新手问题,但我想知道为什么我们必须使用静态方法 (makeText) 来创建 Toast 而不是构造函数。 为什么我们必须使用这个: makeText(Context context, C
我想显示的 toast 少于 Toast.LENGTH_SHORT,因为我觉得它需要大约 2 秒。我只想显示 toast 半秒。 Toast.LENGTH_SHORT 和 Toast.LENGTH_L
我想向用户显示自定义 toast。但 toast.getView() 和 toast.setView() 在 android studio 中已弃用。 这是我的代码: Toast toast = To
如何在 WorkManager 中显示 toast do work()? 当我尝试时,它会抛出 Caused by: java.lang.RuntimeException: Can't create
我写了一个代码,它工作正常,但没有任何 toast 出现。 Activity 2: package com.example.kiit.questionme2; import android.conte
我刚刚开始学习 Android。我使用我的 MIUI 10 设备进行调试。 我已经学习了非常基础的 App Lifecycle Program。问题是,我正在使用 toasts 来显示何时调用每个方法
我有一条消息在执行后不会消失。我猜这与它处于循环中有关,但我不确定。有人可以帮我弄清楚为什么 toast 消息没有区别吗? @Override public void onClick(View v)
是否可以让手机在您的程序中收到任何 toast 消息时振动?还是必须在每个 toast 上插入振动命令? 干杯。 最佳答案 将此类添加到您的代码中: import android.content.Co
有谁知道为什么这个程序不显示 toast 消息? public class Main extends Activity implements OnClickListener{ /** Called w
我在我的应用程序中打印 Toast 消息以显示通知,但我想知道Toast.LENGTH_LONG 和 Toast.LENGTH_SHORT。我可以使用哪些其他值。 谁能告诉我这两个变量的值是多少? 最
我是一名优秀的程序员,十分优秀!