上次说到了登录回调方法onPostExecute,此方法是AsyncTask的方法,当doInBackground方法执行完后调用此方法来处理返回结果.在onPostExecute中主要根据登录结果来做不同的事情,登录成功://发送登录广播
sendBroadcast(new Intent(Foursquared.INTENT_ACTION_LOGGED_IN));
此广播的订阅时在Foursquared类中实现的,首先看此类Foursquared extends Application,Application是android项目运行的一个全局的状态 "Base class for those who need to maintain global application state". 可以在Manifest.xml中指定你自定义的application. 在此类中有一个LoggedInOutBroadcastReceiver 来处理接收到的广播,然后广播发送一个message.此message对应有一个TaskHandler.在foursquare中他使用了
mTaskThread = new HandlerThread(TAG + "-AsyncThread");
mTaskThread.start();
mTaskHandler = new TaskHandler(mTaskThread.getLooper());
上面的方式来创建Handler. 是为了让handler运行在新的线程中. 接下来看handleMessage方法对msg的处理.第一个switch case语句是MESSAGE_UPDATE_USER, 更新一下用户的信息.同时保存在SharedPreferenses中.
接下来开始一个更新UI的Service foursquared.requestStartService(); 主要调用FoursquaredService类的updateWidgets方法来更新widget.也是在Foursquared类中来进行更新,看handleMessage():
case MESSAGE_START_SERVICE: //updateWidgets更新组件
Intent serviceIntent = new Intent(Foursquared.this, FoursquaredService.class);
serviceIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
startService(serviceIntent);
return;
启动一个FoursquaredService.
接下来返回到主界面
// Launch the main activity to let the user do anything.
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
如果登录失败:
sendBroadcast(new Intent(Foursquared.INTENT_ACTION_LOGGED_OUT));//发送登出广播.
NotificationsUtil.ToastReasonForFailure(LoginActivity.this, mReason);//根据不同的exception来提示失败信息
最后关闭进度条dismissProgressDialog().
到这里登录就结束了.写的比较乱.呵呵.
分享到:
相关推荐
数据集包含168个美国城市的foursquare签到数据,适合做基于地理位置的社交网络的研究
foursquare数据集1-4
Foursquare数据集 Abstract: Foursquare is a location-based social networking website, software for mobile devices. This service is available to users with GPS enabled mobile devices, such as iPhones ...
foursquare开源数据集,供做兴趣点推荐相关算法的人员使用,没有经过处理,大家可以下载根据自己的需要进行数据预处理
grafana的cloudera manager插件,由于开源的grafana cdh插件在集成时会出现dateMath.parse is not a function问题,修复后可直接使用。本资源包是修复问题后的,可直接放到grafana plugins文件夹下,即可使用。
国外LBS--Foursquare案例研究报告 PDF
Foursquare源码 里面登录的代码让我注释掉了,用的时候打开就行
foursquare-ios-api, 用于iOS的Foursquare API v2 用于iOS的 Foursquarefoursquare API的简单 objective-c 包装器。 它允许你将foursquare集成到你的iOS应用程序中。特性简单,小巧,易于使用使用Safari进行身份验证...
android平台foursquarev2.1源代码
foursquare, 用于 python的Foursquare API客户端 foursquare用于 foursquare API的python 包装器。哲学:映射 foursquare one-to-one的端点简洁,简单,Pythonic 调用只处理原始数据,定义你自己的模型功能:pyth
国外著名的LBS社交类应用程序 foursquare源码,供大家分析研究
#Foursquare API-探索整合特征: * Uses Bower* Uses Grunt咕packages包*grunt-contrib-copy*grunt-contrib-cssmin*grunt-contrib-jshint*grunt-contrib-less*grunt-contrib-uglify*grunt-contrib-watch*jshint-...
process-warden.zip,一种有助于避免直接使用它们的陷阱的process/processbuilder包装器,一种通过处理其中的一些gotchas inherit来提高其使用安全性的process和processbuilder包装器。
Unofficial Foursquare® Client for Android Wear. Download: (join the beta) Features: Lightning fast check-in from your watch: Quickly explore your neighbourhood: Future plans report ...
前端开源库-node-foursquare节点foursquare,节点js的容错foursquare/swarm api v2包装器。
您只需走在超声波传感器前面,即可签到家庭/办公室甚至您奶奶的房子。
Foursquare GPS 定位地图交友, 并获取商家打折信息。
插件文档该插件用作现有Foursquare API的grails包装器。 该插件提供的实用程序在与Foursquare API交互时可提供更丰富和连贯的体验。 与传统的API调用相比,使用此插件访问Foursquare API可以得到“自定义”且高度...