Abz Manakibwala Abz Manakibwala - 2 months ago 8
Java Question

ActivityNotFoundException error

This question is for an app that displays an image and description of a website, when clicked on the ListView, a website associated with that description opens up in the browser.

But when i click on one of them an error appears. I have no idea how to fix it, any help will be appreciated.

Here is the error stack:

E/MessageQueue-JNI: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google.com }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3917)
at android.app.Activity.startActivityForResult(Activity.java:3877)
at android.app.Activity.startActivity(Activity.java:4200)
at android.app.Activity.startActivity(Activity.java:4168)
at com.android.ict.seneca.androidpocketguide.Websites.onItemClick(Websites.java:109)
at android.widget.AdapterView.performItemClick(AdapterView.java:310)

at android.app.Activity.dispatchTouchEvent(Activity.java:2765)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9514)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-06 13:39:15.277 11606-11606/com.android.ict.seneca.androidpocketguide D/AndroidRuntime: Shutting down VM
10-06 13:39:15.278 11606-11606/com.android.ict.seneca.androidpocketguide E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.ict.seneca.androidpocketguide, PID: 11606
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google.com }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3917)
at android.app.Activity.startActivityForResult(Activity.java:3877)
at android.app.Activity.startActivity(Activity.java:4200)
at android.app.Activity.startActivity(Activity.java:4168)
at com.android.ict.seneca.androidpocketguide.Websites.onItemClick(Websites.java:109)
at android.widget.AdapterView.performItemClick(AdapterView.java:310)
at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3042)
at android.widget.AbsListView.onTouchUp(AbsListView.java:3891)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3656)
at android.view.View.dispatchTouchEvent(View.java:9294)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2547)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent(Activity.java:2765)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9514)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit


Here is the Java file that handles the website thing:

package com.android.ict.seneca.androidpocketguide;

import android.app.Activity;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class Websites extends Activity
implements AdapterView.OnItemClickListener{


private final String CLASS_NAME = "Websites";


String [] descriptions;
String [] Url;

//int [] images;

/* private static final String[] descriptions = new String[]{
"It is rooted in soil in bodies of water, with leaves and flower floating on the surface.",
"It is a small alpine perennial composite herb of central and southeast Europe.",
"It is a yellow flower that blooms in the spring and that has a center that is shaped like a long tube.",
"It is a large, bright flower that is shaped like a cup and that grows in the spring.",
"Daisies belong to the daisy family of Asteraceae in flowering plants. Daisies are native to north and central Europe.",
"Apple (Malus domestica) blossoms begin their blooming cycle pale pink, gradually fading to pure white as flowering progresses.",
"Begonia is a genus of perennial flowering plants in the family Begoniaceae. They are native to moist subtropical and tropical climates. ",
"The Orchidaceae are a diverse and widespread family of flowering plants, with blooms that are often colourful and often fragrant."
};

private static final Integer[] images = {
R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4,
R.drawable.pic5, R.drawable.pic6, R.drawable.pic7, R.drawable.pic8};
*/

private ListView listView;
private List<RowItem> rowItems;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_websites);

descriptions= getResources().getStringArray(R.array.descriptions_array);
Url = getResources().getStringArray(R.array.url_array);


TypedArray ar = getResources().obtainTypedArray(R.array.images_array);
int len = ar.length();

int [] images = new int[len];

for (int i = 0; i < len; i++)
images[i] = ar.getResourceId(i, 0);

ar.recycle();

//images = getResources().getIntArray(R.array.images_array);

rowItems = new ArrayList<RowItem>();

for (int i = 0; i < descriptions.length; i++) {
//imageId, String desc, String url
RowItem item = new RowItem(images[i], descriptions[i], Url[i]);
rowItems.add(item);
}

listView = (ListView) findViewById(R.id.imagelist);

CustomListAdapter adapter = new CustomListAdapter(
this,
R.layout.list_item,
rowItems);

listView.setAdapter(adapter);

listView.setOnItemClickListener(this);
}

@Override
public void onItemClick(AdapterView<?> parent,
View view,
int position,
long id) {

Log.d("website", "a" );
Uri webpage = Uri.parse(rowItems.get(position).getUrl());
Log.d("website", "b" );
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
Log.d("website", "c" );
startActivity(intent);
}

/*
public void openWebPage(String url) {
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
Log.d("Link: ", "a");
startActivity(intent);
}//startActivityForResult( new Intent("com.android.ict.seneca.androidpocketguide.about"),request_Code);
}
*/

public void onStart() {
super.onStart();
Log.d(CLASS_NAME, "onStart invoked!");
}

public void onPause() {
super.onPause();
Log.d(CLASS_NAME, "onPause invoked!!");
}

public void onResume() {
super.onResume();
Log.d(CLASS_NAME, "onResume invoked!!");
}

public void onStop() {
super.onStop();
Log.d(CLASS_NAME, "onStop invoked!!!");
}

public void onDestroy() {
super.onDestroy();
Log.d(CLASS_NAME, "onDestroy INVOKED!!!");
}

public void onRestart() {
super.onRestart();
Log.d(CLASS_NAME, "onRestart invoked!!");
}

}


Here is the RowItems.java that it uses to get and set the varibles:

package com.android.ict.seneca.androidpocketguide;

import android.net.Uri;

public class RowItem {

private int imageId;
private String desc;
private String url;

public RowItem(int imageId, String desc, String url) {
this.imageId = imageId;
this.desc = desc;
this.url = url;
}
public int getImageId() {
return imageId;
}
public void setImageId(int imageId) {
this.imageId = imageId;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}

public String getUrl()
{
return url;
}

@Override
public String toString() {
return desc;
}
}


Here is the Strings.xml file:

<resources>
<string name="app_name">Android Pocket Guide</string>
<string name="create_new">About</string>
<string name="action_help">Help</string>
<string name="full_name">Abbas Zoeb</string>
<string-array name="Vocabularies_array">
<item>activity</item>
<item>AVD</item>
<item>ART</item>
<item>Dalvik</item>
<item>intent</item>
<item>intent filter</item>
<item>explicit intent</item>
<item>implicit intent</item>
<item>LogCat</item>
<item>bundle</item>
<item>Gradle</item>
<item>Android Device Monitor</item>
<item>SDK manager</item>
<item>minSdkVersion</item>
</string-array>

<string-array name="meanings_array">
<item>An activity represents a single screen with a user interface just like window or frame of Java.</item>
<item>An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.</item>
<item>Android Runtime (ART) is an application runtime environment used by the Android operating system.</item>
<item>Dalvik is a part of the software stack that makes up the Android platform.</item>
<item>Intent can be defined as a simple message objects which is used to communicate from 1 activity to another.</item>
<item>Specifies the types of intents that an activity, service, or broadcast receiver can respond to.</item>
<item>An explicit intent is one that you use to launch a specific app component, such as a particular activity or service in your app.</item>
<item>Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.</item>
<item>Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the Log class.</item>
<item>A Bundle is a set of key/value pairs, where it implements an interface called Parcelable.</item>
<item>Gradle is a custom build tool used to build android packages (apk files) by managing dependencies and providing custom build logic.</item>
<item>Android Device Monitor is a standalone tool that provides a UI for several Android application debugging and analysis tools.</item>
<item>A software development kit that enables developers to create applications for the Android platform.</item>
<item>An integer designating the minimum API Level required for the application to run.</item>
</string-array>

<string-array name="descriptions_array">
<item>Google is an American multinational technology company specializing in Internet-related services and products that include online advertising technologies, search, cloud computing, and software.</item>
<item>YouTube is an American video-sharing website headquartered in San Bruno, California, United States.</item>
<item>Facebook (stylized as facebook) is a for-profit corporation and online social media and social networking service based in Menlo Park, California, United States.</item>
<item>Baidu offers many services, including a Chinese search engine for websites, audio files and images.</item>
<item>Yahoo Inc. (also known simply as Yahoo!, styled as YAHOO!) is an American multinational technology company headquartered in Sunnyvale, California.</item>
<item>Amazon.com, Inc. (/ˈæməzɒn/ or /ˈæməzən/), often referred to as simply Amazon, is an American electronic commerce and cloud computing company with headquarters in Seattle, Washington. </item>
<item>Wikipedia (Listeni/ˌwɪkᵻˈpiːdiə/ or Listeni/ˌwɪkiˈpiːdiə/ wik-i-pee-dee-ə) is a free online encyclopedia that allows its users to edit almost any article.</item>
<item>Tencent QQ, popularly known as QQ, is an instant messaging software service developed by a Chinese company named Tencent Holdings Limited.</item>
</string-array>

<string-array name="url_array">
<item>google.com</item>
<item>youtube.com</item>
<item>facebook.com</item>
<item>baidu.com</item>
<item>yahoo.com</item>
<item>amazon.com</item>
<item>wikipedia.com</item>
<item>tencent.com</item>
</string-array>


<array name="images_array">
<item>@drawable/pic1</item>
<item>@drawable/pic2</item>
<item>@drawable/pic3</item>
<item>@drawable/pic4</item>
<item>@drawable/pic5</item>
<item>@drawable/pic6</item>
<item>@drawable/pic7</item>
<item>@drawable/pic8</item>
</array>

</resources>

Answer

Have you tried to put http:// or https:// to URL resources?

Example: Instead of google.com, http://google.com

I think, this change will solve this exception:

E/MessageQueue-JNI: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google.com }