Android的内容activitynotfoundexception无活动处理的意图 - 试图去URL时, [英] android content activitynotfoundexception no activity found to handle intent - when trying to go to url

查看:200
本文介绍了Android的内容activitynotfoundexception无活动处理的意图 - 试图去URL时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个应用程序,你可以输入一个地址,然后你重定向到Google地图。 (我想这就是所谓的隐性意图)

- 我已经创建了一个意向,推出的主要活动,这是在我的应用程序的唯一活动。
主要活动包括一些文本,EditField中和一个按钮的。

AndroidManifest.xml中:

 <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.example.where_do_you_live
安卓版code =1
机器人:=的versionName1.0><用途-SDK
    安卓的minSdkVersion =8
    机器人:targetSdkVersion =15/><应用
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>
    <活动
        机器人:名字=。MainActivity
        机器人:标签=@字符串/ title_activity_main>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
< /用途>
<使用许可权的android:NAME =android.permission.INTERNET对/>< /清单>

这是code的按钮:

 公共无效Button1Click(查看视图)
{
    尝试
    {
        addressField =(EditText上)findViewById(R.id.address);        。字符串地址= addressField.getText()的toString();
        地址= address.replace('','+');
        意图geoIntent =新意图(android.content.Intent.ACTION_VIEW,
            Uri.parse(地理:0,0 Q =?+地址));
        startActivity(geoIntent);    }    赶上(例外五)
    {
        TextView的电视=(的TextView)findViewById(R.id.textView1);
        tv.setText(e.toString());
        //找到的东西    }}


解决方案

如果您在仿真器中测试这个,事情比在一个设备的不同。

在你创建你的Andr​​oid虚拟设备,您应该选择谷歌的API作为目标。如果没有安装它们,则可以使用SDK管理器来下载。

看一看这个

I am trying to write an app where you can type in an address and then you get redirected to google maps. (I suppose this is called implicit intent)

-I have created an intent to launch the main activity, which is the only activity in my app. The Main activity consists of some text, an editfield and a button.

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>

this is the code for the button:

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

    }

}

解决方案

If you are testing this in emulator, things are different than in a device.

When you are creating your Android Virtual Device, you should select Google APIs as your target. If you do not have them installed, you can use SDK Manager to download it.

Have a look at this.

这篇关于Android的内容activitynotfoundexception无活动处理的意图 - 试图去URL时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆