【问题标题】:How to make a live Twitterfeed like Google IO 2011 application?如何制作像 Google IO 2011 应用程序这样的实时 Twitter 提要?
【发布时间】:2011-05-05 17:17:06
【问题描述】:

我不知道您是否已经测试过 Google IO 应用程序,但是有一个很酷的功能可以显示所有推文,包括 Google IO 主题标签。

我真的很想为我的用户提供相同的功能。

我可以使用 API 做类似的事情,但我必须创建一个自定义列表视图,解析 XML/JSON 提要,这太复杂了! 当然,此列表不会自动更新,而是实时供稿

在应用程序中,我刚刚看到,当我关闭wifi时,这确实是一个带有这个url的webview:

http://www.google.com/search?%20tbs=mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q=%23io2011&btnG=Search

这是应用程序的屏幕截图和浏览器中的相同网址

高分辨率图片:http://cl.ly/3q1r0c2J3H163E3G2p2X

但是在 webview 中使用这个 url 只会显示谷歌搜索,并且不提供相同的功能。

我知道这个应用程序肯定是开源的,但我对谷歌承诺的“未来几天内”持否定态度。 我们还在等待 Twitter 应用源代码!

【问题讨论】:

  • 澄清一下:如果您已经知道 WebView 中使用的 URL 是什么,并且您可以轻松地使用它来构建您自己的查询的 URL,那么您还在寻找什么?
  • 我添加了一个截图:在应用程序中,它显示图片等。在浏览器或网络视图中,这是一个经典的谷歌搜索。

标签: android twitter feed tweets


【解决方案1】:

如果您等到会议结束后,您将找到应用程序here 的源代码。您还可以在此处找到去年的应用程序源代码。

更新:

刚刚查看了源代码,您几乎是对的。这是一个带有以下 URL 的 webview:http://www.google.com/search?tbs=mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q=%23io2011&btnG=Search,所以看起来你可能不小心把 %20 放​​在那里了。

代码:

public static final String EXTRA_QUERY = "com.google.android.iosched.extra.QUERY";

public static final String CONFERENCE_HASHTAG = "#io2011";

private String mSearchString;

//onCreate()
final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
mSearchString = intent.getStringExtra(EXTRA_QUERY);
if (TextUtils.isEmpty(mSearchString)) {
    mSearchString = CONFERENCE_HASHTAG;
}
if (!mSearchString.startsWith("#")) {
    mSearchString = "#" + mSearchString;
}

//onCreateView
mWebView = (WebView) root.findViewById(R.id.webview);

mWebView.post(new Runnable() {
    public void run() {
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
        try {
            mWebView.loadUrl(
                    "http://www.google.com/search?tbs="
                    + "mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q="
                    + URLEncoder.encode(mSearchString, "UTF-8")
                    + "&btnG=Search");
        } catch (UnsupportedEncodingException e) {
            Log.e(TAG, "Could not construct the realtime search URL", e);
        }
    }
});

【讨论】:

【解决方案2】:

可能使用带有限制的Loaders API 实现。 也等不及源码了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-04
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多