61877

Android:ActivityNotFoundException

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...

<strong>logcat result</strong>:

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 }

<strong>AndroidManifest.xml</strong>

<?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); }

Answer1:

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 <strong>activities</strong> 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.

Answer2:

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

Recommend

  • AndroidTest Manifest permission not detected
  • Google Maps blank on real Android device - but works on Emulator
  • Android - get file path of a selected pdf, doc, ppt or xls in my app
  • Android not responding if Debugging. If not in Debug app works normally
  • How to set a URL scheme/link for a react-native app
  • Dynamically Impersonate a remote user - c# and asp.net
  • What is the difference between running in VS 2010 and running a builded EXE?
  • Converting a data frame into named object in R
  • Referring to individual variables in … with dplyr quos
  • Convert data type in R or Python
  • PhoneGap : How to upload APK files on Google Play Store
  • Android NFC read Tags issue. Activity starts each time on data received
  • Is there a way to link a linux's thread TID and a pthread_t “thread ID”
  • Phonegap GA plugin not working
  • Send data from edittext to listview
  • How can go in last activity with resume button?
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • CSS bleed-through with cfinput type=“datefield”
  • Possible to get mouse events fired when cursor is outside page?
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • Android application: how to use the camera and grab the image bytes?
  • Play WS (2.2.1): post/put large request
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Seeking advice on Jetty HttpClient Hang
  • Deserializing XML into class C#
  • what is the difference between the asp.net mvc application and asp.net web application
  • Google cloud sdk not working when python points python3
  • Is there a mandatory requirement to switch app.yaml?
  • Cannot Parse HTML Data Using Android / JSOUP
  • using HTMLImports.whenReady not working in chrome
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Getting Messege Twice Using IMvxMessenger
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Android Heatmap on canvas or ImageView
  • java string with new operator and a literal
  • How to load view controller without button in storyboard?