应用程序每次在手机上运行时都会崩溃.有什么不对?它说不幸的是"appname"已经停止工作了.我也尝试过其他方法来检查googleplay服务,但它总是崩溃.我更新了我的谷歌播放服务,并有一个正常工作的谷歌地图v2.该代码的任何解决方案?它在运行Android 4.1.2和我的AVD的手机上崩溃了.
package com.example.checkgoogleplayproject;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
public class MainActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
// Getting reference to TextView to show the status
TextView tvStatus = (TextView)findViewById(R.id.tv_status);
// Getting status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
// Showing status
if(status==ConnectionResult.SUCCESS)
tvStatus.setText("Google Play Services are available");
else{
tvStatus.setText("Google Play Services are not available");
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}
}
@Override …Run Code Online (Sandbox Code Playgroud) android ×1