将控制从Android应用程序移动到浏览器

时间:2016-01-19 14:38:39

标签: android baseadapter

其实我正在使用listView进行facebook feedlike视图的应用程序。而且我在Feed中有一个网址。当我点击该Url时,我需要使用该URL访问浏览器以进行搜索。因此,当我使用ListView时,我应该扩展BaseAdapter。任何人都可以告诉我如何将控制从我的应用程序转移到浏览器。我该怎么用我尝试使用

browserIntent = new Intent(Intent.ACTION_VIEW,    Uri.parse("http://some url"));
startActivity(browserIntent);

但它不能在扩展基本适配器的类中工作,我该如何解决问题。在此先感谢。如果答案是疯狂的,那就很抱歉。

1 个答案:

答案 0 :(得分:2)

请参阅以下示例应用程序,其中包含您可以执行的所有代码,以连接网站和Android应用程序。

https://github.com/commonsguy/cw-advandroid/tree/master/Introspection/URLHandler

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:host="www.this-so-does-not-exist.com" android:scheme="http" />
</intent-filter>

将此项添加到您要从网站导航的活动下方的清单文件中