2012-07-17 22 views
5

我想寫一個應用程序,你可以輸入一個地址,然後你重定向到谷歌地圖。 (我認爲這被稱爲隱含意圖)安卓內容activitynotfoundexception沒有找到處理意圖的活動 - 當試圖去url

- 我創建了一個意圖,啓動主要活動,這是我的應用程序中唯一的活動。 主要活動由一些文本,一個編輯區和一個按鈕組成。

的AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.where_do_you_live" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="15" /> 

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/title_activity_main" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 
<uses-permission android:name="android.permission.INTERNET" /> 

</manifest> 

這是該按鈕的代碼:

public void Button1Click(View view) 
{  
    try 
    { 
     addressField=(EditText)findViewById(R.id.address); 

     String address=addressField.getText().toString(); 
     address=address.replace(' ','+'); 
     Intent geoIntent=new Intent(android.content.Intent.ACTION_VIEW, 
      Uri.parse("geo:0,0?q=" + address)); 
     startActivity(geoIntent); 

    } 

    catch(Exception e) 
    { 
     TextView tv=(TextView)findViewById(R.id.textView1); 
     tv.setText(e.toString()); 
     //finding stuff 

    } 

} 
+0

您確定您的谷歌地圖已經安裝在您的設備上? – Erol 2012-07-17 16:49:05

+0

該設備是一個模擬器,所以我必須? – Ken 2012-07-17 17:27:44

回答

5

如果你是在模擬器測試此,事情比在設備不同。

當您創建Android虛擬設備時,您應該選擇Google API作爲您的目標。如果你沒有安裝它們,你可以使用SDK Manager下載它。

看一看this

enter image description here

+0

非常感謝。這解決了我的問題:-) – Ken 2012-07-17 18:20:40

+0

不客氣! – Erol 2012-07-17 19:44:03

+0

我在真實設備中遇到了這個問題,當我在google地圖中顯示點並按谷歌搜索引擎 – 2016-01-28 16:34:30

相關問題