资源简介
android 统计
核心源码:
package com.umeng.example.analytics; import java.util.HashMap; import java.util.Map; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.umeng.analytics.MobclickAgent; import com.umeng.analytics.social.UMPlatformData; import com.umeng.analytics.social.UMPlatformData.GENDER; import com.umeng.analytics.social.UMPlatformData.UMedia; import com.umeng.example.R; import com.umeng.ui.BaseSinglePaneActivity; public class AnalyticsHome extends BaseSinglePaneActivity { private Context mContext; private final String mPageName = "AnalyticsHome"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; MobclickAgent.setDebugMode(true); // SDK在统计Fragment时,需要关闭Activity自带的页面统计, // 然后在每个页面中重新集成页面统计的代码(包括调用了 onResume 和 onPause 的Activity)。 MobclickAgent.openActivityDurationTrack(false); // 设置地理位置信息setLocation(double lat,double lng) // AnalyticsConfig.setLocation(20, 100); // MobclickAgent.setSessionContinueMillis(2000); MobclickAgent.updateOnlineConfig(this); } @Override public void onResume() { super.onResume(); MobclickAgent.onPageStart( mPageName ); MobclickAgent.onResume(mContext); } @Override public void onPause() { super.onPause(); MobclickAgent.onPageEnd( mPageName ); MobclickAgent.onPause(mContext); } /** * android:onClick="onButtonClick" * @param view */ public void onButtonClick(View view){ int id = view.getId(); switch( id){ case R.id.umeng_example_analytics_online_config: String onlineParams= MobclickAgent.getConfigParams(mContext, "abc");//the demo param's key is 'abc' if(onlineParams.equals("")){ Toast.makeText(mContext, "Get No Online Params", Toast.LENGTH_SHORT).show(); }else Toast.makeText(mContext, "Online Params:" onlineParams, Toast.LENGTH_SHORT).show(); break; case R.id.umeng_example_analytics_event: MobclickAgent.onEvent(mContext, "click"); MobclickAgent.onEvent(mContext, "click", "button"); break; case R.id.umeng_example_analytics_ekv: Map<String, String> map_ekv = new HashMap<String, String>(); map_ekv.put("type", "popular"); map_ekv.put("artist", "JJLin"); MobclickAgent.onEvent(mContext, "music", map_ekv); break; case R.id.umeng_example_analytics_duration: // 'MobclickAgent.onEventDuration' is deprecated, pls use 'MobclickAgent.onEventValue' instead. // MobclickAgent.onEventDuration(mContext, "book", 12000); // MobclickAgent.onEventDuration(mContext, "book", "chapter1", 23000); // // Map<String, String> map_du = new HashMap<String, String>(); // map_du.put("type", "popular"); // map_du.put("artist", "JJLin"); // // MobclickAgent.onEventDuration(mContext, "music", map_du, 2330000); Map<String, String> map_value = new HashMap<String, String>(); map_value.put("type", "popular"); map_value.put("artist", "JJLin"); MobclickAgent.onEventValue(this, "music", map_value, 12000); break; case R.id.umeng_example_analytics_event_begin: //when the events start MobclickAgent.onEventBegin(mContext, "music"); MobclickAgent.onEventBegin(mContext, "music", "one"); Map<String, String> map = new HashMap<String, String>(); map.put("type", "popular"); map.put("artist", "JJLin"); MobclickAgent.onKVEventBegin(mContext, "music", map, "flag0"); break; case R.id.umeng_example_analytics_event_end: MobclickAgent.onEventEnd(mContext, "music"); MobclickAgent.onEventEnd(mContext, "music", "one"); MobclickAgent.onKVEventEnd(mContext, "music", "flag0"); break; case R.id.umeng_example_analytics_make_crash: "123".substring(10); break; case R.id.umeng_example_analytics_js_analytic: startActivity( new Intent( this, WebviewAnalytic.class) ); break; case R.id.umeng_example_analytics_flush: MobclickAgent.flush(this); break; case R.id.umeng_example_analytics_fragment_stack: startActivity( new Intent(this, FragmentStack.class)); break; case R.id.umeng_example_analytics_fragment_tabs: startActivity( new Intent(this, FragmentTabs.class)); break; case R.id.umeng_example_analytics_social: UMPlatformData platform = new UMPlatformData(UMedia.WEIXIN_CIRCLE, "user_id"); platform.setGender(GENDER.MALE); //optional platform.setWeiboId("weiboId"); //optional MobclickAgent.onSocialEvent(this, platform); break; } } @Override protected Fragment onCreatePane() { return new AnalyticsHomeDashboardFragment(); } public static class AnalyticsHomeDashboardFragment extends Fragment { @Override public void onAttach(Activity activity) { super.onAttach(activity); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.umeng_example_analytics, container,false); } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Hook(); return true; } return super.onKeyDown(keyCode, event); } ///对于好多应用,会在程序中杀死 进程,这样会导致我们统计不到此时Activity结束的信息, ///对于这种情况需要调用 'MobclickAgent.onKillProcess( Context )' ///方法,保存一些页面调用的数据。正常的应用是不需要调用此方法的。 private void Hook(){ AlertDialog.Builder builder = new AlertDialog.Builder( mContext ); builder.setPositiveButton("退出应用", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { MobclickAgent.onKillProcess( mContext ); int pid = android.os.Process.myPid(); android.os.Process.killProcess(pid); } }); builder.setNeutralButton("后退一下", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); } }); builder.setNegativeButton("点错了", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); builder.show(); } }
代码片段和文件信息
/*
* Copyright (C) 2010 Johan Nilsson
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.markupartist.android.widget;
import java.util.linkedList;
import android.content.ActivityNotFoundException;
import android.content.Conte
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-09 15:53 res\
目录 0 2014-04-09 15:53 res\anim\
文件 279 2014-04-09 15:53 res\anim\umeng_fb_slide_in_from_left.xm
文件 281 2014-04-09 15:53 res\anim\umeng_fb_slide_in_from_right.xm
文件 280 2014-04-09 15:53 res\anim\umeng_fb_slide_out_from_left.xm
文件 278 2014-04-09 15:53 res\anim\umeng_fb_slide_out_from_right.xm
目录 0 2014-04-09 15:53 res\drawable\
文件 294 2014-04-09 15:53 res\drawable\umeng_common_gradient_green.xm
文件 294 2014-04-09 15:53 res\drawable\umeng_common_gradient_orange.xm
文件 294 2014-04-09 15:53 res\drawable\umeng_common_gradient_red.xm
文件 1172 2014-04-09 15:53 res\drawable\umeng_fb_arrow_right.png
文件 1476 2014-04-09 15:53 res\drawable\umeng_fb_back_normal.png
文件 1578 2014-04-09 15:53 res\drawable\umeng_fb_back_selected.png
文件 472 2014-04-09 15:53 res\drawable\umeng_fb_back_selector.xm
文件 229 2014-04-09 15:53 res\drawable\umeng_fb_bar_bg.9.png
文件 477 2014-04-09 15:53 res\drawable\umeng_fb_btn_bg_selector.xm
文件 8431 2014-04-09 15:53 res\drawable\umeng_fb_conversation_bg.png
文件 294 2014-04-09 15:53 res\drawable\umeng_fb_gradient_green.xm
文件 294 2014-04-09 15:53 res\drawable\umeng_fb_gradient_orange.xm
文件 368 2014-04-09 15:53 res\drawable\umeng_fb_gray_fr
文件 322 2014-04-09 15:53 res\drawable\umeng_fb_list_item.9.png
文件 328 2014-04-09 15:53 res\drawable\umeng_fb_list_item_pressed.9.png
文件 313 2014-04-09 15:53 res\drawable\umeng_fb_list_item_selector.xm
文件 3939 2014-04-09 15:53 res\drawable\umeng_fb_logo.png
文件 310 2014-04-09 15:53 res\drawable\umeng_fb_point_new.xm
文件 310 2014-04-09 15:53 res\drawable\umeng_fb_point_normal.xm
文件 2979 2014-04-09 15:53 res\drawable\umeng_fb_reply_left_bg.9.png
文件 265 2014-04-09 15:53 res\drawable\umeng_fb_reply_right_bg.9.png
文件 949 2014-04-09 15:53 res\drawable\umeng_fb_see_list_normal.png
文件 1059 2014-04-09 15:53 res\drawable\umeng_fb_see_list_pressed.png
文件 314 2014-04-09 15:53 res\drawable\umeng_fb_see_list_selector.xm
............此处省略418个文件信息
- 上一篇:android 图片浏览器
- 下一篇:android 高仿易信
相关资源
- Android开发中相当便捷的JSON反序列化实
- android 下拉瀑布流显示图片效果
- android 音量控制 ,效果不错
- android 实现圆形菜单
- 将PC电脑端的文件通过usb传到android手
- android 瀑布流 完整实例源码下载3655
- android ViewPager 左右双向滑动
- android 视频录制与播放
- android 加密处理解密处理
- android 银联支付
- android 对话框
- android 自定义Toast颜色
- android 前面部分可以编辑后面部分不可
- android win8界面风格扁平化设计点击动
- android 蓝牙连接打印机
- android UPNP
- android 计算自己手机的屏幕宽高,de
- android 一键锁屏,android4.2测试通过
- android 滑动解锁源码
- android spinner intent 参数传递
- android widget小部件开发
- android 定时进入飞行模式 例子源码下
- Android调用谷歌STMP发送邮件
- android 简单的截屏
- android 下拉滑动刷新List
- android textview 展示图片
- Android 基于author2.0的新浪微博 源码,
- android 树状ListView 自定义列表 源码
- Android移动开发一本就够源码
- 监听android应用被卸载后 再使用libcu
评论
共有 条评论