【发布时间】:2016-03-29 19:48:39
【问题描述】:
我正在尝试为没有在我设置的模拟器上获得谷歌播放服务的用户测试逻辑(不使用谷歌 API)。正如预期的那样,尝试使用 Google 登录会弹出“获取 google play 服务”对话框,但按下对话框中的按钮只会导致 logcat 出现错误:
SettingsRedirect:无法重定向到 Google Play 服务的应用设置
我想知道这是否仅仅是因为我使用了模拟器,或者它是否表明我的代码中存在可能影响用户的错误? (即如果有办法让这个按钮在模拟器上工作)
编辑:我检查 gps 方法的代码:
public static boolean checkPlayServices(Activity activity, String actionWeArePerforming) {
Timber.i("checkPlayServices: called by %s because of %s", activity.getClass().getSimpleName(), actionWeArePerforming);
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(activity);
int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
if (resultCode != ConnectionResult.SUCCESS) {
Timber.d("checkPlayservices: resultcode was not success");
if (googleApiAvailability.isUserResolvableError(resultCode)) {
Timber.d("checkPlayServices: update available - resolving");
// "user resolvable" means Google Play is available to download the last version of Play Services APK
// This will open Google dialog fragment displaying the proper message depending on "resultCode"
googleApiAvailability.showErrorDialogFragment(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST);
} else {
Timber.d("checkPlayServices: update not available");
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) activity
.findViewById(android.R.id.content)).getChildAt(0);
// Should not happen. This device does not support Play Services.
// Let's show an ultimate warning.
Snackbar.make(viewGroup, activity.getString(R.string.cannot_download_google_play_services), Snackbar.LENGTH_LONG);
}
Timber.i("checkPlayServices: returning false");
return false;
}
Timber.i("checkPlayServices: returning true");
return true;
}
【问题讨论】:
-
你能发布一些代码吗?当模拟器中为我弹出对话框并单击它时,它不会崩溃。什么都没有发生。
-
它对我来说也不会崩溃 - 但它不会进入任何谷歌播放服务下载页面,所以我想知道这是否是我可以用模拟器测试的逻辑范围跨度>
-
您找到解决方案了吗?
-
@TimAutin 不幸的是,除了我在这里写的内容之外,什么都没有
-
好的,谢谢!我想我们必须自己做......
标签: java android google-play-services emulation google-signin