简体   繁体   中英

How can i call Ionic Application in Android Application's user interface

As i have two different application built on different platform one on Android and another on Ionic.

I want to call ionic application from Android Application using click event.

Button button = (Button)findViewById(R.id.button);
    if (button != null) {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Call ionic application here
            }
        });
    }

"actually, I think you can do that using webView" I am giving a code snippet below:

public class IonicActivity extends AppCompatActivity {
    WebView mywebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mywebView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = mywebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mywebView.loadUrl("http://localhost/8080");
    mywebView.setWebViewClient(new WebViewClient());
}

@Override
public void onBackPressed() {
    if (mywebView.canGoBack()) {
        mywebView.goBack();
    } else {
        super.onBackPressed();
    }
}

}

"you can take this as a separate activity, and then can use explicit intent with the button. I hope this works , if not let me know, will try another way " "use layout file too with a WebView, "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM