问题描述
应用程序崩溃每次我我的手机上运行它。有什么不对?它说,遗憾的是APPNAME已停止工作。我也尝试过其他方法来检查GOOGLEPLAY服务,但它总是崩溃。我更新了我的谷歌播放服务,并有一个工作谷歌地图V2完美的工作。这个code的任何解决方案?它崩溃上运行Android 4.1.2我的手机和我AVD。
包com.example.checkgoogleplayproject;进口android.app.Activity;
进口android.app.Dialog;
进口android.os.Bundle;
进口android.view.Menu;
进口android.widget.TextView;进口com.google.android.gms.common.ConnectionResult;
进口com.google.android.gms.common.GooglePlayServicesUtil;公共类MainActivity延伸活动{ @覆盖
保护无效onResume(){
super.onResume(); //获取参考TextView的显示状态
TextView的tvStatus =(的TextView)findViewById(R.id.tv_status); //获取状态
INT状态= GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); //显示状态
如果(状态== ConnectionResult.SUCCESS)
tvStatus.setText(谷歌播放服务是可用);
其他{
tvStatus.setText(谷歌播放服务不可用);
INT申请code = 10;
对话的对话= GooglePlayServicesUtil.getErrorDialog(状态,为此,请求code);
dialog.show();
}
} @覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
} @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
//充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.main,菜单);
返回true;
}
}
谢谢你们您的答复。我只是理解了它从我的LogCat中。
我必须包括这在我的Android清单。
<应用>
&所述;元数据
机器人:名字=com.google.android.gms.version
机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION/>
...
Application Crashes every time I run it on my phone. Is there something wrong? It says Unfortunately "appname" has stopped working. I have also tried other approaches to checking for googleplay services but it always crashes. I updated my google play services and have a working google map v2 working perfectly. Any solutions to this code? It crashes on my phone running android 4.1.2 and on my 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
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Thanks guys for your responses. I just figured it out from my LogCat.I had to include this in my Android Manifest.
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
...
这篇关于检查是否正确谷歌播放服务提供:&QUOT;不幸的是应用程序已停止工作&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!