----------2014 4 12更新--------------------- 随着新版uc和pocket中文版的发布,也不知道是哪方做出了改动,总之现在已经能直接从uc分享到pocket了!速速更新吧哈哈,这个uc2pocket也成为了历史,不再提供更新和维护 ------------------------------------
----------2014 4 12更新---------------------
随着新版uc和pocket中文版的发布,也不知道是哪方做出了改动,总之现在已经能直接从uc分享到pocket了!速速更新吧哈哈,这个uc2pocket也成为了历史,不再提供更新和维护
----------------------------------------------------------
不知道何时起uc已经不能分享到pocket了,作为pocket和uc重度用户,这绝逼不能忍
可能的情况就是uc的发送的intent与pocket的intent-filter不切合,uc2pocket就是起到一个适配器的作用
先附上apk的地址,需要的童鞋就直接拿去吧uc2pocket下载地址 百度盘
思路 利用apktools反编译pocket文件,得到它的manifest.xml关键代码
这就是pocket接收分享的intent-filter。于是就照着这么写
intent intent = new intent(intent.action_send); intent.setclassname(com.pocket.cn,com.ideashower.readitlater.activity.addactivity); //intent.putextra(intent.extra_subject, midintent.getstringextra(intent.extra_subject)); string originurl=midintent.getstringextra(intent.extra_text); intent.putextra(intent.extra_text, geturlfromucshare(originurl)); intent.settype(text/plain); intent.addcategory(intent.category_default); if(mainactivity.isintentavailable(mainactivity.this, intent)){ mainactivity.this.startactivity(intent); }
而
intent.setclassname(com.pocket.cn,com.ideashower.readitlater.activity.addactivity);
包名我是查钛备份得到,其实人家manifest文件就有写着呢。。而activity名就是上面反编译得到manifest.xml文件后就知道了。话说addactivity这个名字简洁直观,大赞
关于接收uc的intent那就比较方便了,条件也不苛刻,我就直接从keep的filter那儿拷贝了过去,这里到时候再修改
从uc得到的extra-text是 网页名加上地址的,需要提取出地址 ,还没有验证混合的情况下会是什么情况
public static string geturlfromucshare(string originstr){ pattern p=pattern.compile([a-za-z]+://[^\\s]*); matcher matcher = p.matcher(originstr); if (matcher.find()) { string result= originstr.substring(matcher.start(), matcher.end()); return result; } else return null; }
另外开发中还遇到了 分享到pocket时候提示 不是有效的地址。后来发现原来是要求http:// 打头的。如果你直接分享www.google.com而不是http://www.google.com,那pocket就会提示非有效的地址。。。在stackoverflow有个类似的问题http://stackoverflow.com/questions/16108356/share-to-pocket ,应该这个就是原因
再附上一个显示bundle所有内容的函数,当时用于测试intent的内容时使用的
bundle b=midintent.getextras(); set keyset =b.keyset(); //获取所有的key, for(string key : keyset){ //bundle.get(key);来获取对应的value tvstate.settext(tvstate.gettext()+key+ : +midintent.getstringextra(key)+\n);//开始 }
附上源码地址 在csdn code https://code.csdn.net/dashboard/index