我想在 url 加载完成时将 webview 重定向到另一个 Activity 完全的。这是我的 webview 代码:- 此类由 webview 扩展
** 1) This the method where I am doing code for redirecting webview to activity**
> 这是加载 url 的 onPagefinished 方法。
public void onPageFinished(WebView view, String url) {
if (url.endsWith("paymentconfirmation/"))
((DibsPaymentScreen) getContext())
.setCancelDisallowed(false);
if (callbackUrl.equals(url)
&& statusCancelled.equals(paymentData.params
.get(statusKey))) {
paymentResultListener.cancelUrlLoaded();
} else if (callbackUrl.equals(url)
&& statusAccepted.equals(paymentData.params
.get(statusKey))) {
paymentResultListener.paymentAccepted(paymentData.params);
} else if (!windowIsLoaded) {
paymentWindowLoaded();
}
super.onPageFinished(view, url);
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.equals("http://nmotion.dk/paymentconfirmation/")) {
Intent intent = new Intent(getContext(),
RestaurantsListScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getContext().startActivity(intent);
return true;
}
return false;
}
最佳答案
你必须在 WebView WebViewCLient 中实现 on finish loader
webview.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
// create your intent here
super.onPageFinished(view, url);
}
});
编辑白衣提供的代码
public void onPageFinished(WebView view, String url) {
if (url.equals("http://nmotion.dk/paymentconfirmation/")) {
Intent intent = new Intent(getContext(), RestaurantsListScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getContext().startActivity(intent);
return true;
} else {
if (url.endsWith("paymentconfirmation/")){
((DibsPaymentScreen) getContext()).setCancelDisallowed(false);
}
if (callbackUrl.equals(url) && statusCancelled.equals(paymentData.params.get(statusKey))) {
paymentResultListener.cancelUrlLoaded();
} else if (callbackUrl.equals(url)
&& statusAccepted.equals(paymentData.params.get(statusKey))) {
paymentResultListener.paymentAccepted(paymentData.params);
} else if (!windowIsLoaded) {
paymentWindowLoaded();
}
super.onPageFinished(view, url);
}
关于android - 想要在 webview android 中完成 url 加载后将 webview 重定向到其他 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27837354/
我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex
我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.
我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co
我需要一些关于TDD概念的帮助。假设我有以下代码defexecute(command)casecommandwhen"c"create_new_characterwhen"i"display_inventoryendenddefcreate_new_character#dostufftocreatenewcharacterenddefdisplay_inventory#dostufftodisplayinventoryend现在我不确定要为什么编写单元测试。如果我为execute方法编写单元测试,那不是几乎涵盖了我对create_new_character和display_invent
我正在使用RubyonRails3.0.9,我想生成一个传递一些自定义参数的link_toURL。也就是说,有一个articles_path(www.my_web_site_name.com/articles)我想生成如下内容:link_to'Samplelinktitle',...#HereIshouldimplementthecode#=>'http://www.my_web_site_name.com/articles?param1=value1¶m2=value2&...我如何编写link_to语句“alàRubyonRailsWay”以实现该目的?如果我想通过传递一些