4

I have a TextView with some linkification(twitter style):

Pattern pattern1 = Pattern.compile("@\\w+");
Linkify.addLinks(textView, pattern1, "my_activity://one=");
Pattern pattern2 = Pattern.compile("#\\w+");
Linkify.addLinks(textView, pattern2, "my_activity://two=");

Activity declared in manifest with following intent filter:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="my_activity" />
</intent-filter>

Intent gets caught in the onNewIntent method of the activity but the activity gets restarted before that(I assume this is default behaviour).

Is there a way to receive such intent without restarting activity?

Mykhailo Gaidai
  • 3,130
  • 1
  • 21
  • 23
  • What is the launchMode of the activity? Post the whole tag from your manifest – David Wasser Jun 27 '12 at 14:42
  • sorry for the delay - launchmode was default. the problem was solved by setting launchmode to `singleInstance`(`singleTask` should work too). – Mykhailo Gaidai Jul 11 '12 at 13:50
  • Can you create an answer and accept it? Otherwise this ends up in the list of 'unanswered questions'. You shouldn't use `singleInstance`, as that is only for HOME-screen replacements. Actually, you should try `singleTop`. That should be enough for what you are trying to do. – David Wasser Jul 11 '12 at 14:03
  • Didn't know about the `singleInstance` nuance. Can you add your last comment as answer? I'll accept it :) – Mykhailo Gaidai Jul 11 '12 at 14:49
  • Done. Thanks. Let me know if singleTop works. – David Wasser Jul 11 '12 at 14:54

1 Answers1

4

Looks like launchMode is the problem. You shouldn't use singleInstance, as that is only for HOME-screen replacements. You should try singleTop. That should be enough for what you are trying to do.

David Wasser
  • 93,459
  • 16
  • 209
  • 274