Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android content activitynotfoundexception no activity found to handle intent - when trying to go to url

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

    }

}
like image 579
Ken Avatar asked Jul 17 '12 15:07

Ken


People also ask

Could not open URL Whatsapp app ': No activity found to handle intent?

You see no activity found to handle intent when you attempt to launch an intent either to open a link or to access an app component. It's an error message that is caused because the device is not an official android, Google Play is not supported, or it's a rooted device.

What is Intentfilter?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

What is an intent in Java?

An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver,start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents. Here is a sample example to start new activity with old activity.


1 Answers

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.

enter image description here

like image 171
Erol Avatar answered Sep 27 '22 18:09

Erol