跳至主要内容

博文

目前显示的是 十二月, 2012的博文

how to close input method in android code

open input method activity window: InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); // accept input text imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED); close input method activity window InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow( OpeListActivity.this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS); if input method activity close open else close it InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); get input method status InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); boolean isOpen=imm.isActive(); isOpen if opened return true, else false

如何得到优酷网mp4格式视频文件url

前言 众所周知,视频在网页中使用FLV格式是最常用和方便的(原因你懂得),但是当我们在移动平台上就会遇到麻烦(FLASH不被这些移动设备支持,为啥?我也不知道!)但是这样一个需求来了,在Android平台上播放YouKu的视频。 So, 我就开始研究了! 分析 经过一番研究我发现,他们其实是有另外一个格式的视频存在,但是需要成为他们的合作伙伴(也就是想用的得意思意思)。因此得出结论方法有二: 成为他们的合作伙伴(这得花点买路钱)。 条条大路通罗马,绕道走。 过程 方法一,这里就不讨论了。我们主要讲方法二(如何绕道)。 第一步:网页内嵌的播放地址 例如:http://player.youku.com/player.php/Type/Folder/Fid/18117290/Ob/1/sid/XNDQ0MDQzMTgw/v.swf 猜测可得出“XNDQ0MDQzMTgw”这一段为视频的索引也就是ID 而优酷android app请求服务器的url为: http://api.3g.youku.com/layout/phone2_1/play?point=1&id=XNDQ0MDQzMTgw&pid=352e7f78a0bc479b&format=4&language=guoyu&audiolang=1&guid=c7a0fd9f8f19ea5cbafde16f327f8004&ver=2.3.1&operator=%E4%B8%AD%E5%9B%BD%E8%81%94%E9%80%9A_46001&network=WIFI 返回值是一个json数据如下: { "status":"success", "lang":"", "title":"\u5916\u4ea4\u90e8\u56de\u5e94\u65e5\u9a7b\u534e\u5927 \u4f7f\u5750\u8f66\u60ac\u6302\u7684\u56fd\u65d7\u88ab\u62a2\uff1a\u4e2d\u65b9\u6b63\u57

how to hook android app function use html with javascript

为什么要这么做 在使用html开发手机端的时候我们就会常请求app来拿到手机内的数据,这时候我们就会用到接下来我要讲到的内容 怎么做 一开始我也一头雾水,没做过。 但是不要怕,跟着哥哥走,你会发现原来这很简单 这么做 我们的需求暂定如下 我们要加载一个html,在这个html里写一段javascript检查手机是否已经开启网络连接,如果没有开启网络连接我们给出提示,如果网络连接没有开启不能加载webview默认的错误页面(那样太不专业了) So 跟着哥哥的脚步,一步一步来 先看这个类(其实这个就是我们准备在javascript中调用的类) // call from html private final class JsResload { @SuppressWarnings("unused") public void reload() { reloadWebView(); } } reloadWevView文件实体如下 private void reloadWebView() { if (hasNetwork()) { mWebView.loadUrl(BluelionReading.BASE_API_URL + BookMethods.BOOK_STORE, getHeadersMap()); } else { Toast.makeText(this, getString(R.string.network_notgelivable_refresh), Toast.LENGTH_SHORT).show(); mWebView.loadUrl(DEFAULT_PAGE); } } 其中的常量值如下: public static final String BOOK_STORE = "/bookstore"; private static final String DEFAULT_PAGE = "file:///android_asset/about/wrong.html"; 关键还是在这里,如何使用javascri