首页 文章 精选 留言 我的

精选列表

搜索[移动应用云],共10000篇文章
优秀的个人博客,低调大师

一种提高Android应用进程存活率新方法(下)

接上文 创建 Account服务 publicclassXXAuthServiceextendsService{ privateXXAuthenticatormAuthenticator; @Override publicvoidonCreate(){ mAuthenticator=newXXAuthenticator(this); } privateXXAuthenticatorgetAuthenticator(){ if(mAuthenticator==null) mAuthenticator=newXXAuthenticator(this); returnmAuthenticator; } @Override publicIBinderonBind(Intentintent){ returngetAuthenticator().getIBinder(); } classXXAuthenticatorextendsAbstractAccountAuthenticator{ privatefinalContextcontext; privateAccountManageraccountManager; publicXXAuthenticator(Contextcontext){ super(context); this.context=context; accountManager=AccountManager.get(context); } @Override publicBundleaddAccount(AccountAuthenticatorResponseresponse,StringaccountType,StringauthTokenType,String[]requiredFeatures,Bundleoptions) throwsNetworkErrorException{ //添加账号示例代码 finalBundlebundle=newBundle(); finalIntentintent=newIntent(context,AuthActivity.class); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,response); bundle.putParcelable(AccountManager.KEY_INTENT,intent); returnbundle; } @Override publicBundlegetAuthToken(AccountAuthenticatorResponseresponse,Accountaccount,StringauthTokenType,Bundleoptions) throwsNetworkErrorException{ //认证示例代码 StringauthToken=accountManager.peekAuthToken(account,getString(R.string.account_token_type)); //ifnot,mightbeexpired,registeragain if(TextUtils.isEmpty(authToken)){ finalStringpassword=accountManager.getPassword(account); if(password!=null){ //getnewtoken authToken=account.name+password; } } //withoutpassword,needtosignagain finalBundlebundle=newBundle(); if(!TextUtils.isEmpty(authToken)){ bundle.putString(AccountManager.KEY_ACCOUNT_NAME,account.name); bundle.putString(AccountManager.KEY_ACCOUNT_TYPE,account.type); bundle.putString(AccountManager.KEY_AUTHTOKEN,authToken); returnbundle; } //noaccountdataatall,needtodoasign finalIntentintent=newIntent(context,AuthActivity.class); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,response); intent.putExtra(AuthActivity.ARG_ACCOUNT_NAME,account.name); bundle.putParcelable(AccountManager.KEY_INTENT,intent); returnbundle; } @Override publicStringgetAuthTokenLabel(StringauthTokenType){ //thrownewUnsupportedOperationException(); returnnull; } @Override publicBundleeditProperties(AccountAuthenticatorResponseresponse,StringaccountType){ returnnull; } @Override publicBundleconfirmCredentials(AccountAuthenticatorResponseresponse,Accountaccount,Bundleoptions) throwsNetworkErrorException{ returnnull; } @Override publicBundleupdateCredentials(AccountAuthenticatorResponseresponse,Accountaccount,StringauthTokenType,Bundleoptions) throwsNetworkErrorException{ returnnull; } @Override publicBundlehasFeatures(AccountAuthenticatorResponseresponse,Accountaccount,String[]features) throwsNetworkErrorException{ returnnull; } } } 声明Account服务 <service android:name="**.XXAuthService" android:exported="true" android:process=":core"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> 其中authenticator为: <?xmlversion="1.0"encoding="utf-8"?> <account-authenticatorxmlns:android="http://schemas.android.com/apk/res/android" android:accountType="@string/account_auth_type" android:icon="@drawable/icon" android:smallIcon="@drawable/icon" android:label="@string/app_name" /> 使用Account服务 同SyncAdapter,通过AccountManager使用 。申请Token主要是通过 AccountManager.getAuthToken)系列方法 。添加账号则通过 AccountManager.addAccount) 。查看是否存在账号通过 AccountManager.getAccountsByType) Refs 微信Android客户端后台保活经验分享 Android Low Memory Killer原理 stackOverflow 上介绍的双Service方法 Write your own Android Sync Adapter Write your own Android Authenticator Android developer android.accounts AccountManager AbstractAccountAuthenticator AccountAuthenticatorActivity Creating a Sync Adapter Android篇从底层实现让进程不被杀死(失效Closed) Android 4.3+ NotificationListenerService 的使用 Going multiprocess on Android 本文作者:佚名 来源:51CTO

优秀的个人博客,低调大师

共享单车物联网应用重心从智能锁转移到电子围栏

在短短的一年多的时间里, 城市的大街小巷已经被橙、黄、绿、蓝、白、金、彩等各色共享单车所攻占,今年4月份开始,物联网“电子围栏”开始成为共享单车界的新话题,各地政府部门喜闻乐见,甚至单车品牌是否具有电子围栏成为某些地区的准入门槛。以摩拜、OfO为首的共享单车龙头开始进入到刷技术的阶段.共享单车电子围栏简单来说,“电子围栏”就是一个个虚拟的停车框,用户必须将车辆停在指定的停车框中,否则无法锁车结束行程。具体而言,通过物联网芯片发射信号覆盖技术,给共享单车停放划定一个区域,让单车只能停放在规定范围内。当车辆停放超出系统规定的区域时,系统会发出语音提示,要求骑行者将车辆返回至指定区域,否则车辆将无法上锁,后台也将会一直计费。 共享单车电子围栏的两种形式,一种是由政府统一规划的“公共电子围栏”,另一种是有共享单车企业自行设置的独立电子围栏,但在实际落地过程中,两种电子围栏也有重合的可能,例如OfO和北京经信委联合开发出了全国首个电子围栏技术,并在北京通州试点。两种电子围栏设置目的都在于限制停车位置,共享单车通过一定的定位技术识别用户是否将车停放在指定区域内,从而对用户进行奖励或惩罚。 共享单车实行的电子围栏主要有两种,一种是通过在地面建立信号发射装置来实现对停车区域的识别,有基于短距离无线通信技术而实现的,也有基于蓝牙实现的(如摩拜、小鸣单车);另一种是北斗导航提出的基于卫星定位技术的电子围栏系统(OfO),借助地面增强系统,北斗系统的定位精度可以达到亚米级,完胜GPS!高定位精度除了解决找车难问题,对于监管问题也是一把利器。 我们可以看到除了共享单车相关企业在积极推动之外,地方政府也参与了进来。共享单车已经由于过渡的铺设带来了明显的城市管理隐患,是时候到了政府介入携手共同规范化的阶段。深圳北航物联网研究院(www.buaaiot.org)相关人员认为通过“电子围栏”来规范化停车,是目前从技术角度来讲较为可行的约束手段,不过这会不会成为另一种形式的“定点桩”,还得看用户怎么想。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册