2014-09-02 87 views
2

我想打開活動時,用戶與linkify TextView的點擊... 繼承人我的代碼:與Linkify Android開放活動

Pattern tagMatcher = Pattern.Compile("#([A-Za-z0-9_-]+)"); 

      //Scheme for Linkify, when a word matched tagMatcher pattern, 
      //that word is appended to this URL and used as content URI 
      String newActivityURL = "content://Solution.Project.WelcomeActivity"; 
      //Attach Linkify to TextView 
      wrapper.Text.Text = post.PostText; 
      Linkify.AddLinks(wrapper.Text, tagMatcher, newActivityURL); 

和我的Android manifest.xml

<application android:icon="@drawable/Icon" android:label="Welcome"> 
    <activity android:name=".WelcomeActivity" android:label="@string/WelcomeText"> 
     <intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
     </intent-filter> 
    </activity> 
</application> 

當用戶點擊textView,它拋出以下異常:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://Solution.Project.welcomeactivity (has extras) } 

回答

2

你的意圖過濾器應如下:

<intent-filter android:label="@string/filter_title_viewgizmos"> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos」 --> 
    <data android:scheme="content" 
      android:host="Solution.Project.WelcomeActivity" /> 

</intent-filter> 

你缺少數據標籤如下圖所示

計劃可能是http或您自己定製的。

主機是鏈接如xyz.com

pathPrefix是可選的喜歡/主頁

<data android:scheme="content" 
      android:host="Solution.Project.WelcomeActivity" /> 

android Documentation for Deep Linking

0

您的活動使用provider標籤相匹配的authority

+0

我天璣明白¿? – user2743074 2014-09-02 18:21:33

+0

[閱讀本文](http://developer.android.com/guide/topics/manifest/provider-element.html) – bhargavg 2014-09-02 18:22:25