Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:17:07+00:00 2026-06-09T16:17:07+00:00

I have a TextView in my ArrayAdapter that may contain some hyperlinks. For those

  • 0

I have a TextView in my ArrayAdapter that may contain some hyperlinks. For those links I use Linkify:

public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = convertView;
    if (rowView == null) {
        rowView = inflater.inflate(R.layout.list_item_2, null);
        holder = new ViewHolder();

        holder.content = (TextView) rowView.findViewById(R.id.postContent);
        holder.date = (TextView) rowView.findViewById(R.id.postDate);

        rowView.setTag(holder);
    } else {
        holder = (ViewHolder) rowView.getTag();
    }

    holder.content.setText(contents.get(position));
    holder.date.setText(dates.get(position));

    Linkify.addLinks(holder.content, Linkify.ALL);

    return rowView;
}

But because the Linkify is added in the ArrayAdapter, I get an exception saying this:

08-05 16:42:16.715: E/AndroidRuntime(20598): FATAL EXCEPTION: main
08-05 16:42:16.715: E/AndroidRuntime(20598): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
08-05 16:42:16.715: E/AndroidRuntime(20598):    at android.app.ContextImpl.startActivity(ContextImpl.java:921)
08-05 16:42:16.715: E/AndroidRuntime(20598):    at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
08-05 16:42:16.715: E/AndroidRuntime(20598):    at android.text.style.URLSpan.onClick(URLSpan.java:62)

How can I make this work? I can’t think of an alternative.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:17:09+00:00Added an answer on June 9, 2026 at 4:17 pm

    Looking at the exception in the log, it seems that you used the application context when you allocate your ArrayAdapter. For example, if your code looks similar to the following:

        listView.setAdapter(new ArrayAdapter<String>(context,
                android.R.layout.simple_list_item_1,
                data) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                // ...
            }
        });
    

    You must have initialized the context variable above with the application context, like this:

        Context context = getApplicationContext();
    

    To avoid the error, you should have initialized it with your Activity instance instead:

        Context context = this;
    

    Or, if your code is in a Fragment:

        Context context = getActivity();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a custom ArrayAdapter so I can use the Title/Subtitle view that
Guess that I have a TextView that I want to update it in some
I have a custom ArrayAdapter I use to manage my ListView: public class FilesAdapter
I have an ArrayAdapter (myAdapter) attached to an AutoCompleteTextView (textView) component. Once the user
I have textView in my cell and sometimes during tableView scroll some weird calls
I have a TextView that displays an error message in the login page of
I want to have a TextView on the left that fills space, plus a
I have a Spinner with an ArrayAdapter that feeds Values into it. The layout
I have a listview with a custom arrayadapter that handles about 15 strings. The
I have a ListView that is filled with items of an ArrayAdapter. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.