检查谷歌播放服务

时间:2016-05-09 07:26:15

标签: android google-cloud-messaging

让我疯狂的是,谷歌文档中经常会忽略文档的重要性。如果我不是秃头,我会把头发拔掉。

private _studentList:Student[]=[];

    .subscribe(
            returnedStudents => {
              console.log(returnedStudents);
              this._studentList = returnedStudents;
            },
            erroMsg => this._errorMessage = erroMsg
          ) 

上面的代码显示一个对话框,上面有一个按钮,读取 获取谷歌播放服务

def readFile(fileName):
    with open(fileName, 'r') as f:
        List = [line.strip().split(',') for line in f if line.strip()]
    return List

现在我该怎么办?我应该如何引导用户访问Play商店以获取playservices的更新?我认为 def readFile2(fileName): with open(fileName, 'r') as f: List = [] for line in f: if line.strip(): List.append(line.strip().split(',')) return List 在这里有用,但我不知道该怎么做。

请帮助我。

2 个答案:

答案 0 :(得分:3)

您可以使用以下方式查看Google Play服务:

if (checkPlayServices()) {
    // Do your calculation here.
}

private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                    .show();
        } else {
            Log.i(TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}

这有助于您查看Google Play服务。

答案 1 :(得分:2)

您可以使用此代码在App Store上打开Goog​​le Play服务页面:

try {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE)));
} catch (android.content.ActivityNotFoundException anfe) {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE)));
}