当前位置: 首页 > news >正文

淘宝客如何建设推广网站兰州app开发

淘宝客如何建设推广网站,兰州app开发,现代简约室内设计案例分析,网络营销方式变化背后的逻辑与趋势大家好#xff0c;我系苍王。以下是我这个系列的相关文章#xff0c;有兴趣可以参考一下#xff0c;可以给个喜欢或者关注我的文章。[Android]如何做一个崩溃率少于千分之三噶应用app--章节列表Google爸爸#xff0c;听说要将一些插件化hook系统的变量属性禁用#xff0c;…大家好我系苍王。以下是我这个系列的相关文章有兴趣可以参考一下可以给个喜欢或者关注我的文章。[Android]如何做一个崩溃率少于千分之三噶应用app--章节列表Google爸爸听说要将一些插件化hook系统的变量属性禁用Android P之后很可能将会不再有插件化、热更新、主题变换、资源加固等骚操作。试图hook你将会看到 NoSuchFieldException 或者 NoSuchMethodException 等错误提示。可见文章Android P 调用隐藏API限制原理中对api隐藏说明具体通过hide的注释让属性提示变量不存在。这样就会要求app上线前测试更加严谨而不是在上线后通过各种修复替换功能等方式每周发版的日子将不会出现了不停歇的加班。RN技术其原理涉及到view的渲染暂时并未受到波及。现在国内有继续走RN的各大厂有走类似小程序方向的快应用都是使用js语法写web还能拯救一堆程序猿啊。接下来说一下进程通信其实任何的进程通信方式都可以在组件化开发中使用。Android中进程间通信的方式1.Aidl2.Messenger3.Content provider4.Socket5.文件共享前三个都是基于binder机制实现的。本节想要介绍的是使用aidl做的进程通信单单使用aidl进行通信其实并不难。原理也有很多文章介绍过但是如何设计一个通用的aidl通信架构就需要考究了。这里介绍的是ModularizationArchitecture中使用的aidl的通信架构。ModularizationArchitecture通信架构这里ModularizationArchitecture架构使用了aidl作为路由传输的实现。文件结构1.每个需要通信的module都需要继承MaProvider类然后在BaseApplicationLogic启动的时候注册。2.MaAction作为触发的事件继承出来改写其方法invoke方法是事件实现。需要在MaProvider中注册事件。3.MaActionResult是事件结果回调。4.LocalRouter是当前进程调用MaAction中的invoke执行方法。5.WideRouter是跨进程调用时使用需要在MaApplication启动的时候注册将module中的的LocalRouterConnectService。注册提供内容注册进程路由信息到广域路由中public class MyApplication extends MaApplication {//注册进程路由信息到广域路由Overridepublic void initializeAllProcessRouter() {WideRouter.registerLocalRouter(com.spinytech.maindemo,MainRouterConnectService.class);WideRouter.registerLocalRouter(com.spinytech.maindemo:music,MusicRouterConnectService.class);WideRouter.registerLocalRouter(com.spinytech.maindemo:pic,PicRouterConnectService.class);}//初始化进程启动Overrideprotected void initializeLogic() {registerApplicationLogic(com.spinytech.maindemo,999, MainApplicationLogic.class);registerApplicationLogic(com.spinytech.maindemo,998, WebApplicationLogic.class);registerApplicationLogic(com.spinytech.maindemo:music,999, MusicApplicationLogic.class);registerApplicationLogic(com.spinytech.maindemo:pic,999, PicApplicationLogic.class);}//是否使用多进程Overridepublic boolean needMultipleProcess() {return true;} } 复制代码进程初始化的时候注册MaProvider到进程路由中public class MainApplicationLogic extends BaseApplicationLogic {Overridepublic void onCreate() {super.onCreate();//注册ProviderLocalRouter.getInstance(mApplication).registerProvider(main,new MainProvider());} } 复制代码为每个Provider绑定可以触发的Action任务public class MainProvider extends MaProvider {Overrideprotected void registerActions() {registerAction(sync,new SyncAction());registerAction(async,new AsyncAction());registerAction(attachment,new AttachObjectAction());} } 复制代码下面是进程内同步通信进程内同步通信进程内调用RouterResponse response LocalRouter.getInstance(MaApplication.getMaApplication()) //进程中单例LocalRouter.route(MainActivity.this, RouterRequest.obtain(MainActivity.this) //在缓存池中获取请求.provider(main) //设定provider.action(sync) //设定调用的action.data(1, Hello) //设定数据.data(2, World)); 复制代码通过注册的内容找到相应的action然后调用action中的invoke方法public RouterResponse route(Context context, NonNull RouterRequest routerRequest) throws Exception {Logger.d(TAG, Process: mProcessName \nLocal route start: System.currentTimeMillis());RouterResponse routerResponse new RouterResponse();// Local request//检查domain是不是在同一个进程if (mProcessName.equals(routerRequest.getDomain())) {HashMapString, String params new HashMap();Object attachment routerRequest.getAndClearObject();params.putAll(routerRequest.getData());Logger.d(TAG, Process: mProcessName \nLocal find action start: System.currentTimeMillis());//通过provider索引到actionMaAction targetAction findRequestAction(routerRequest);routerRequest.isIdle.set(true);Logger.d(TAG, Process: mProcessName \nLocal find action end: System.currentTimeMillis());routerResponse.mIsAsync attachment null ? targetAction.isAsync(context, params) : targetAction.isAsync(context, params, attachment);// Sync result, return the result immediately// 同步调用.if (!routerResponse.mIsAsync) {//调用action的实现MaActionResult result attachment null ? targetAction.invoke(context, params) : targetAction.invoke(context, params, attachment);//包装responserouterResponse.mResultString result.toString();routerResponse.mObject result.getObject();Logger.d(TAG, Process: mProcessName \nLocal sync end: System.currentTimeMillis());} 复制代码下面是进程内异步通信进程内异步通信[图片上传中...(屏幕快照 2018-03-30 下午12.36.03.png-c9d7e7-1522384627443-0)]route方法中在mIsAsync设定是否异步public RouterResponse route(Context context, NonNull RouterRequest routerRequest) throws Exception {Logger.d(TAG, Process: mProcessName \nLocal route start: System.currentTimeMillis());RouterResponse routerResponse new RouterResponse();// Local request//检查domain是不是在同一个进程if (mProcessName.equals(routerRequest.getDomain())) {...// Sync result, return the result immediately// 同步调用.if (!routerResponse.mIsAsync) {...}// Async result, use the thread pool to execute the task.//异步调用else {//创建异步任务LocalTask task new LocalTask(routerResponse, params,attachment, context, targetAction);//通过线程池调用routerResponse.mAsyncResponse getThreadPool().submit(task);} 复制代码异步调用任务是使用Callback任务 //使用Future Callable的方式使用线程池private class LocalTask implements CallableString {private RouterResponse mResponse;private HashMapString, String mRequestData;private Context mContext;private MaAction mAction;private Object mObject;public LocalTask(RouterResponse routerResponse, HashMapString, String requestData,Object object, Context context, MaAction maAction) {this.mContext context;this.mResponse routerResponse;this.mRequestData requestData;this.mAction maAction;this.mObject object;}Overridepublic String call() throws Exception {//调用action中的invoke方法MaActionResult result mObject null ? mAction.invoke(mContext, mRequestData) : mAction.invoke(mContext, mRequestData, mObject);mResponse.mObject result.getObject();Logger.d(TAG, Process: mProcessName \nLocal async end: System.currentTimeMillis());return result.toString();}} 复制代码下面是跨进程通信跨进程通信使用aidl调用广域的WideRouter//检查domain是不是在同一个进程if (mProcessName.equals(routerRequest.getDomain())) {...}// IPC requestelse {//获取进程domainString domain routerRequest.getDomain();String routerRequestString routerRequest.toString();routerRequest.isIdle.set(true);//检查是不已经绑定了广域路由WideRouterif (checkWideRouterConnection()) {Logger.d(TAG, Process: mProcessName \nWide async check start: System.currentTimeMillis());//If you dont need wide async check, use routerResponse.mIsAsync false; replace the next line to improve performance.//检查是同步还是异步routerResponse.mIsAsync mWideRouterAIDL.checkResponseAsync(domain, routerRequestString);Logger.d(TAG, Process: mProcessName \nWide async check end: System.currentTimeMillis());}// Has not connected with the wide router.else {//调用连接广域路由WideRouterrouterResponse.mIsAsync true;ConnectWideTask task new ConnectWideTask(routerResponse, domain, routerRequestString);routerResponse.mAsyncResponse getThreadPool().submit(task);return routerResponse;}//同步调用if (!routerResponse.mIsAsync) {//aidl传输给相关进程的LocalRouterConnectServicerouterResponse.mResultString mWideRouterAIDL.route(domain, routerRequestString);Logger.d(TAG, Process: mProcessName \nWide sync end: System.currentTimeMillis());}// Async result, use the thread pool to execute the task.//异步调用else {//设定广域调用任务WideTask task new WideTask(domain, routerRequestString);routerResponse.mAsyncResponse getThreadPool().submit(task);}}//返回ReouterResponsereturn routerResponse; 复制代码广域路由连接检测调用aidl连接到WideRouterConnectService private class ConnectWideTask implements CallableString {private RouterResponse mResponse;private String mDomain;private String mRequestString;public ConnectWideTask(RouterResponse routerResponse, String domain, String requestString) {this.mResponse routerResponse;this.mDomain domain;this.mRequestString requestString;}Overridepublic String call() throws Exception {Logger.d(TAG, Process: mProcessName \nBind wide router start: System.currentTimeMillis());//绑定WideRouterConnectServiceconnectWideRouter();int time 0;while (true) {//等待广域路由绑定完成if (null mWideRouterAIDL) {try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}time;} else {break;}//超过30秒就放弃抛出错误if (time 600) {ErrorAction defaultNotFoundAction new ErrorAction(true, MaActionResult.CODE_CANNOT_BIND_WIDE, Bind wide router time out. Can not bind wide router.);MaActionResult result defaultNotFoundAction.invoke(mApplication, new HashMapString, String());mResponse.mResultString result.toString();return result.toString();}}Logger.d(TAG, Process: mProcessName \nBind wide router end: System.currentTimeMillis());//调用关于路由传输到对应的进程路由String result mWideRouterAIDL.route(mDomain, mRequestString);Logger.d(TAG, Process: mProcessName \nWide async end: System.currentTimeMillis());return result;}} 复制代码WideRouterConnectService对对应的进程路由分发通信监听返回。//广域路由处理IWideRouterAIDL.Stub stub new IWideRouterAIDL.Stub() {Overridepublic boolean checkResponseAsync(String domain, String routerRequest) throws RemoteException {//检查是否异步调动return WideRouter.getInstance(MaApplication.getMaApplication()).answerLocalAsync(domain, routerRequest);}Overridepublic String route(String domain, String routerRequest) {try {//广域路由分发到对应的进程路由中return WideRouter.getInstance(MaApplication.getMaApplication()).route(domain, routerRequest).mResultString;} catch (Exception e) {e.printStackTrace();return new MaActionResult.Builder().code(MaActionResult.CODE_ERROR).msg(e.getMessage()).build().toString();}}Overridepublic boolean stopRouter(String domain) throws RemoteException {//停止连接进程路由return WideRouter.getInstance(MaApplication.getMaApplication()).disconnectLocalRouter(domain);}}; 复制代码根据domain分发到对应进程的ILocalRouterAIDLpublic RouterResponse route(String domain, String routerRequest) {Logger.d(TAG, Process: PROCESS_NAME \nWide route start: System.currentTimeMillis());RouterResponse routerResponse new RouterResponse();//是否已经被要求停止任务if (mIsStopping) {MaActionResult result new MaActionResult.Builder().code(MaActionResult.CODE_WIDE_STOPPING).msg(Wide router is stopping.).build();routerResponse.mIsAsync true;routerResponse.mResultString result.toString();return routerResponse;}//广域路由不能作为调用对象if (PROCESS_NAME.equals(domain)) {MaActionResult result new MaActionResult.Builder().code(MaActionResult.CODE_TARGET_IS_WIDE).msg(Domain can not be PROCESS_NAME .).build();routerResponse.mIsAsync true;routerResponse.mResultString result.toString();return routerResponse;}//获取对应进程路由的对象ILocalRouterAIDL target mLocalRouterAIDLMap.get(domain);if (null target) {//是否已经绑定了本地路由没有就启动绑定if (!connectLocalRouter(domain)) {MaActionResult result new MaActionResult.Builder().code(MaActionResult.CODE_ROUTER_NOT_REGISTER).msg(The domain has not registered.).build();routerResponse.mIsAsync false;routerResponse.mResultString result.toString();Logger.d(TAG, Process: PROCESS_NAME \nLocal not register end: System.currentTimeMillis());return routerResponse;} else {// Wait to bind the target process connect service, timeout is 30s.Logger.d(TAG, Process: PROCESS_NAME \nBind local router start: System.currentTimeMillis());int time 0;//等待完成绑定进程连接while (true) {target mLocalRouterAIDLMap.get(domain);if (null target) {try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}time;} else {Logger.d(TAG, Process: PROCESS_NAME \nBind local router end: System.currentTimeMillis());break;}//设定30s超时if (time 600) {MaActionResult result new MaActionResult.Builder().code(MaActionResult.CODE_CANNOT_BIND_LOCAL).msg(Can not bind domain , time out.).build();routerResponse.mResultString result.toString();return routerResponse;}}}}try {Logger.d(TAG, Process: PROCESS_NAME \nWide target start: System.currentTimeMillis());//对应进程调用返回String resultString target.route(routerRequest);routerResponse.mResultString resultString;Logger.d(TAG, Process: PROCESS_NAME \nWide route end: System.currentTimeMillis());} catch (RemoteException e) {e.printStackTrace();MaActionResult result new MaActionResult.Builder().code(MaActionResult.CODE_REMOTE_EXCEPTION).msg(e.getMessage()).build();routerResponse.mResultString result.toString();return routerResponse;}return routerResponse;} 复制代码基本原理就介绍到这里了。1.aidl是google为Android进程通信提供的方式使用了代理模式其内部集成了IBinder使用了Binder的方式通信已经成为套路的规则维护成本低。2.当序列化后的数据单元过大时就会出问题报出android.os.TransactionTooLargeException。其数据量限制为1M3.原理上说就是binder只拷贝一次使用虚拟内存和物理内存页映射比socket高效也安全。4.这里介绍的框架其中是通过本地路由和广域路由间的传送和切换来完成。只能交流变量和调用方法无法通过aidl获取资源。本地路由能力并未有ARouter使用的方便进程内对无法提供获取Fragment View等资源获取可以考虑拓展。但是此本地和广域路由设计非常优秀。5.wutongke有出了一个框架加上编译时注解的优化版github.com/wutongke/Mo…下一节将会继续介绍Messenger进程通信框架敬请期待。Android进程化学习
http://www.zqtcl.cn/news/519488/

相关文章:

  • 济南本地网站自己做的网站怎么置顶
  • wordpress能做多大的站好用的网站后台
  • 想自己做网站流程国家住建网查企业资质
  • 英文网站怎么设计google浏览器入口
  • 重庆网站建设公司魁网个人备案网站名
  • 怀柔营销型网站建设wordpress菜单定制
  • 大连装修网站推广天津市建设信息工程网
  • 服装网站建设建议域名注册最好的网站
  • 小游戏网站网络营销推广岗位
  • 做一百度网站保健品网站建设案例
  • 沙田镇仿做网站如何建设钓鱼网站
  • 如何用域名进网站企业做电商网站有哪些
  • soho做网站网站的k线图怎么做
  • 成都专业的网站建设公司做网站需要哪个专业
  • php彩票网站建设源码有人看片吗免费观看
  • 自己做网站的准备工作营销平台推广
  • 建站网站平台建站工具的优点
  • 各学院二级网站建设通报wordpress 修改admin
  • 网站建设加推广需要多少钱wordpress标签自动生成插件下载
  • 周村区建设局网站石家庄网站运营公司
  • 网站描述怎么设置wordpress仿模板
  • 宁波市网站建设公司h5游戏是什么意思
  • 青岛网站设计案例全栈网站开发
  • 欢迎访问中国建设银行网站个人客户网站建设需要经历什么步骤
  • 建设银行怀柔支行营业部网站企业官网手机版
  • cms那个做网站最好大连网站开发平台
  • 佛山建设外贸网站公司可信网站图标
  • 沈阳.....网站设计连云港优化网站团队
  • 网站添加白名单想学ui设计从哪里入手
  • 做期货与做网站的关系淮安市城市建设档案馆网站