android - how do i disable YouTube video from playing in my webview appwhen the power button or home button is pressed? -


this mainactivity.java file code should input?

public  class  mainactivity  extends actionbaractivity {      final string tag = this.getclass().getname();      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          webview view = (webview) this.findviewbyid(r.id.webview);         view.getsettings().setjavascriptenabled(true);         view.getsettings().setbuiltinzoomcontrols( true );         view.getsettings().setsupportzoom( true );         view.setwebviewclient(new mybrowser());         view.loadurl("http://roestauto.com");     }      private class mybrowser extends webviewclient {         @override         public boolean shouldoverrideurlloading(webview view, string url) {             view.loadurl(url);             return true;         }     }      boolean twice = false;     @override     public void onbackpressed() {          log.d(tag, "click");          if (twice == true){             intent intent = new intent(intent.action_main);             intent.addcategory(intent.category_home);             intent.setflags(intent.flag_activity_clear_top);             startactivity(intent);             finish();             system.exit(0);         }         twice = true;         log.d(tag, "twice: " + twice);   //        super.onbackpressed();         toast.maketext(mainactivity.this, "please press again exit roest auto app", toast.length_short).show();         new handler().postdelayed(new runnable() {             @override             public void run() {                 twice = false;                 log.d(tag, "twice: " + twice);             }         },3000);     } } 


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -