Quick opens the URL with the system browser

Source: Internet
Author: User

Requirements Description:

Add a link to our game, open it directly in the browser, go to the corresponding website, and make some payment activities.

Solve:

So I went to Baidu a bit, found this article, http://blog.csdn.net/teng_ontheway/article/details/9614125. A preliminary glance, the steps are cumbersome, you need to modify C + + code. According to this method, at least the PC can be out of effect.

Later, we found that our leadership solved in a simpler way, using Luajavabridge directly, eliminating the hassle of modifying C + + code, and reducing the workload by N times. Master is the master, the mind is not limited.

1 increased calls in Lua

functionopenbrowser (URL)ifIsadroid () = =true  Then        LocalJavamethodname ="Openbrowser"        LocalJavaparams ={URL}LocalJavamethodsig ="(ljava/lang/string;) V"        LocalOK, ret =Luaj.callstaticmethod (Package_name, Javamethodname, Javaparams, Javamethodsig)ifOk Then            return 1        Else            return-1        End    End    return-1End

2 adding implementations in Java

 Public Static void openbrowser (String url) {                if  (textutils.isempty (URL)) {            return;        }                 = uri.parse (URL);        Intent  new  Intent (Intent.action_view, URI);        S_instance.startactivity (intent);            }

Just 2 steps is that simple.

Self-reflection AH reflection ah.

Quick opens the URL with the system browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.