2014-10-05 84 views
0

我想写一个Android应用程序,它将包含3个按钮,即启动谷歌地图,启动市场和发送电子邮件。我的代码如下:启动谷歌地图

public class Intents extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_intents); 
} 
public void process(View button){ 
    Intent intent=null,chooser=null; 
if(button.getId()==R.id.LaunchMap){ 

    intent=new Intent(android.content.Intent.ACTION_VIEW); 
    intent.setData(Uri.parse("geo:" + latitude + "," + longitude)); 
    chooser=Intent.createChooser(intent, "Launch Google Maps");  
    startActivity(chooser); 

}else if(button.getId()==R.id.LaunchMarket){ 
    intent=new Intent(android.content.Intent.ACTION_VIEW); 
    intent.setData(Uri.parse("market:https://details?id=dolphin.developers.com")); 
    chooser=Intent.createChooser(intent, "Launch Market");  
    startActivity(chooser); 
}else if(button.getId()==R.id.SendEmail){ 

} 

} 
} 

但是,当我在eclipse中运行上述代码我得到“没有应用程序可以执行此操作”。我应该在代码中更改哪些内容或者是否存在我应该添加的任何插件

+0

在什么时候你会得到这个错误?编译时,在模拟器中启动应用程序时,单击按钮或其他东西时? – Okas 2014-10-05 09:26:55

+0

当我按下模拟器上的按钮 – lil 2014-10-05 09:47:37

+0

请确保您使用包含谷歌地图的模拟器图像。 – Okas 2014-10-05 10:12:29

回答

0

要在仿真器中使用Google API-s,必须使用包含Google API-s的模拟器映像。

为是Android 4.4.2(API 19)目前有可用的4张图片:

  • ARM EABI V7A系统映像

  • 英特尔凌动x86的系统映像

  • 谷歌的API( x86系统映像)

  • Google API(ARM系统映像)

只有最后两个支持Google API(包括Google地图),前两个是AOSP图像。

要使用Google API,您首先必须使用Google API安装图像(为了提高速度,尽可能使用带HAX的x86图像)。然后在使用AVD管理器创建虚拟设备时选择此图像作为“目标”。