Android 在此uri com.Google.Earth上找不到Google Earth插件

Android 在此uri com.Google.Earth上找不到Google Earth插件,android,google-earth,google-earth-plugin,Android,Google Earth,Google Earth Plugin,我正试图在android设备上展示2.3.3版的google earth 我尝试了以下代码,要求我“安装谷歌地球”,然后将我重定向到谷歌游戏商店。但是,它会显示一条消息“找不到pname:com.google.earth的结果” 我还将uri更改为“com.google.earth”和“m.google.earth”,但它们都不起作用。 谢谢你的帮助 这是我的密码 package com.example.test; import android.annotation.SuppressLint;

我正试图在android设备上展示2.3.3版的google earth

我尝试了以下代码,要求我“安装谷歌地球”,然后将我重定向到谷歌游戏商店。但是,它会显示一条消息“找不到pname:com.google.earth的结果”

我还将uri更改为“com.google.earth”和“m.google.earth”,但它们都不起作用。 谢谢你的帮助

这是我的密码

package com.example.test;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;

import com.google.android.gms.maps.model.LatLng;

public class MainActivity extends Activity {

  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // the new intent we will launch 
    Intent myIntent = new Intent(); 

    // send the intent directly to the google earth activity that can 
    // handle search 
    myIntent.setClassName("com.google.earth", 
    "com.google.earth.EarthActivity"); 

    // we are doing a search query 
    myIntent.setAction(Intent.ACTION_SEARCH); 

    // change this address to any address you want to fly to 
    myIntent.putExtra(SearchManager.QUERY, "2900 Frenchmen Street, New Orleans, LA"); 

        // always trap for ActivityNotFound in case Google earth is not on the device 

        try { 
          // launch google earth and fly to location 
          this.startActivity(myIntent); 
        } 
    catch (ActivityNotFoundException e) { 
      showGoogleEarthDialog(); 
    } 
}

 private void showGoogleEarthDialog() { 

    AlertDialog.Builder downloadDialog = new AlertDialog.Builder(this); 
    downloadDialog.setTitle("Install Google Earth?"); 
    downloadDialog.setMessage("This application requires Google Earth. Would you like to install it?"); 
    downloadDialog.setPositiveButton("Yes", new 
        DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialogInterface, int i) { 
        Uri uri = Uri.parse("market://search?q=pname:com.google.earth"); //pname:
        Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
        MainActivity.this.startActivity(intent); 
      } 
    }); 
    downloadDialog.setNegativeButton("No", new 
        DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialogInterface, int i) {} 
    }); 
    downloadDialog.show(); 
  } 
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
  }

}

我在这里找到了解决办法。基本上,我的意图是不正确地启动google活动。所以我对下面的代码做了修改,谷歌地图显示在activity fine上

package com.example.test;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

import com.google.android.gms.maps.model.LatLng;

public class MainActivity extends FragmentActivity{

   static final LatLng HAMBURG = new LatLng(18.533333, 73.866667);
   static final LatLng KIEL = new LatLng(53.551, 9.993);
   private com.google.android.gms.maps.GoogleMap map;

  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Uri uri = Uri.parse("geo:18.533333,73.866667");
    Intent it = new Intent(Intent.ACTION_VIEW,uri);
    startActivity(it);
 }
}

我认为在你试图运行代码的设备中需要一个谷歌播放服务。所以请确保设备中安装了google play服务。是的,我已经安装了google play服务。应用程序将我重定向到google play,但无法在play stor中找到google.earth。