Coder Social home page Coder Social logo

uniapp-plugin-android's Introduction

uniapp原生插件开发for Android

此教程需要有一定的Android开发基础、Android Studio使用基础、uniapp开发基础、Weex基础。         

首先需要明确的是,uniapp调用插件就类似于js调用java代码【说不定内部就是这么实现的】,所以需要明确插件可以提供给uniapp哪些参数以及有哪一些回调值,即数据双向交互问题;      

   本教程以uniapp调用Android的Toast来显示消息为例【只是作为本教程的demo方便理解插件的开发流程,实际Toast已经被uniapp封装好了,性能更优,项目开发中直接使用即可】,uniapp需要传递消息给Android来通过Toast显示,调用成功之后Android返回调用结果给uniapp,这样就完成了一个最简单的双向数据交互场景;具体效果如下:

点击按钮:

<button type="primary" plain="true" @click="showRichAlert()">
通过Toast显示“hello uniapp for android plugin”
</button>

调用插件显示消息,调用成功之后显示返回的结果:

   Toast.show({
                    msg: "hello uniapp for android plugin"
                }, function(res) {                  
                    console.log(res.result);
                });

效果图:

这里写图片描述

具体教程见博客:https://blog.csdn.net/qq137722697

uniapp-plugin-android's People

Contributors

huangdali avatar

Stargazers

 avatar shapl avatar marud avatar  avatar

Watchers

James Cloos avatar

Forkers

ylwb wemecan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.