2
public void onContacts(View v)
{
    Intent i=new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI);
    startActivity(i);
}

public void onBrowse(View v)
{

    String s1= et1.getText().toString();
    Intent i= new Intent(Intent.ACTION_VIEW, Uri.parse(s1));
    startActivity(i);

}

public void onSearch(View v)
{

    String s1= et2.getText().toString();
    Intent i=new Intent(Intent.ACTION_WEB_SEARCH);
    i.putExtra(SearchManager.QUERY, s1);
    startActivity(i);
}

public void onMap(View v)
{

    String s1= et3.getText().toString();
    Intent i=new Intent(Intent.ACTION_VIEW,Uri.parse("geo:0,0?q="+s1));
    startActivity(i);
}

These are few methods each attached to respective buttons, on clicking any of these button it shows ActivityNotFoundException except the onContacts() method which is not attached to any editext...

logcat result:

 05-27 23:18:42.984: E/AndroidRuntime(714): Caused by:    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google }

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AllIntent"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
<uses-permission android:name="android.permission.CALL_PHONE"/>   

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".AllIntentActivity" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

see if this can help.. I've run the a programme with same function where no string is retrieved from he edittext,i.e the required resources is provided in the method itshelf

source code for the one i'm talking about

public void onContents(View v)
{
    Intent i=new Intent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);
    startActivity(i);
}

public void onBrowser(View v)
{
    Intent i= new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
    startActivity(i);
}

public void onSearch(View v)
{
    Intent i=new Intent(Intent.ACTION_WEB_SEARCH);

    i.putExtra(SearchManager.QUERY, "tapu");
    startActivity(i);       
}

public void onMap(View v)
{
    Intent i=new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=hyderabad"));
    startActivity(i);
}

public void onCall(View v)
{
    Intent i=new Intent(Intent.ACTION_CALL,Uri.parse("tel:9776215312"));
    startActivity(i);
}
DigCamara
  • 5,540
  • 4
  • 36
  • 47
ceanan007
  • 31
  • 6

2 Answers2

2

I think your problem is that there is no Activity for handle the Intent.ACTION_VIEW and Intent.ACTION_WEB_SEARCH actions, to check if there is an Activity for handle your intent you could check this before:

PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;

if the number of Activity in List activities is 0 that means that there is no Activity for handle your Intent by the moment, before trying to start an Activity you should check this first..

EDIT: as we know those Actions are common to android device (maps and web browser), due to this you should check if the URI you are pasing are correct.

jac1013
  • 408
  • 3
  • 11
  • Ok, i tested the code you provide by edit in a real android device (Galaxy Tab) and all worked except for the 'onCall' method (is a wi-fi tablet), so where are you runing your code, emulator or real device? are you sure the URI String are valid URI after you parse them from the EditText or whatever you are getting them? – jac1013 May 29 '13 at 13:44
  • well, then the problem should be when you "process" the data via you EditText, check the String with Log.w before passing it as an argument to the Intent object and go to your log after run the code, there you will know if the URI is corrupted or not. – jac1013 May 30 '13 at 13:55
1

Your Intent URI is wrong. Or rather the content of your TextView isn't constructed in a way which will open the search dialog you're expecting. Try, for example, entering:

google.com/search?q=blah

as your text in your TextView

DigCamara
  • 5,540
  • 4
  • 36
  • 47