我是安卓新手。我想在中心显示 Toast。当没有安装 Google Play 服务时,我想重定向到 Google Play 服务并显示 Toast。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.map_layout);
context = this;
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(resultCode != ConnectionResult.SUCCESS) {
Toast toast = Toast.makeText(context, getString(R.string.install_google_play_service), Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.gms")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}