开发者

How to make a live Twitterfeed like Google IO 2011 application?

I don't know if you already tested the Google IO application, but there is a cool feature displaying all the tweets including Google IO hashtags.

I really would like to offer the same feature to my users.

I can do something similar using the API, but I would have to create a custom listview, parsing XML/JSON feeds and that's quite overcomplicated! and of course this list will not update automatically and be a livefeed.

开发者_如何学编程

In the application, I have just seen that when I turn off wifi, This is indeed a webview with this url:

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

Here is a screenshot of the app and the same url in the browser

High resolution picture: http://cl.ly/3q1r0c2J3H163E3G2p2X

How to make a live Twitterfeed like Google IO 2011 application?

But using this url in a webview display only a google search, and does not offer same feature.

I know this app will certainly be opensources, but i am so negative about "within next days" that google promise. We are still waiting for the Twitter app source code!


If you wait 'til after the conference is over, you'll find the source code for the app here. You'll also find last year's application's source code there.

Update:

Just viewed the source code, and you're almost right. It's a webview with this URL: http://www.google.com/search?tbs=mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q=%23io2011&btnG=Search so it just seems you put %20 in there by accident maybe.

Code:

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);
        }
    }
});


Probably implemented with Loaders API with throttling. Impatiently waiting for source code as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜