protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); handler = new Handler(); mainPresenter = new MainPresenter(this); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.Title = Resources.GetString(Resource.String.daily); SetSupportActionBar(toolbar); fm = SupportFragmentManager; bottomBar = BottomBar.AttachShy((CoordinatorLayout)FindViewById(Resource.Id.coordinatorLayout), FindViewById(Resource.Id.swipeRefreshLayout), bundle); bottomBar.UseFixedMode(); bottomBar.SetItems(Resource.Menu.bottombar_menu); bottomBar.SetOnMenuTabClickListener(this); MobclickAgent.SetDebugMode(true); MobclickAgent.OpenActivityDurationTrack(false); MobclickAgent.SetScenarioType(this, MobclickAgent.EScenarioType.EUmNormal); updManager = IFlytekUpdate.GetInstance(this); updManager.SetDebugMode(true); updManager.SetParameter(UpdateConstants.ExtraWifionly, "true"); updManager.SetParameter(UpdateConstants.ExtraNotiIcon, "true"); updManager.SetParameter(UpdateConstants.ExtraStyle, UpdateConstants.UpdateUiDialog); updManager.AutoUpdate(this, this); }
async void GetKbArticleContent(Action callBack) { try { var result = await HttpClient.KbArticlesService.GetKbArticles(AccessTokenUtil.GetToken(this), ID); if (result.Success) { string content = result.Data; firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(content); content = content.ReplaceHtml().Trim('"'); content = HtmlUtil.ReadHtml(Assets).Replace("#body#", content).Replace("#title#", kbArticles.Title).Replace("#author#", "作者:" + kbArticles.Author).Replace("#date#", "发布日期:" + kbArticles.DateAdded.ToString("yyyy年MM月dd日 HH:mm")); wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null); callBack(); } else { AlertUtil.ToastShort(this, result.Message); callBack(); } } catch (Exception ex) { AlertUtil.ToastShort(this, ex.Message); MobclickAgent.ReportError(this, ex.ToString()); callBack(); } }
async void GetArticleContent(Action successCallBack) { try { var result = await HttpClient.ArticleService.GetArticle(AccessTokenUtil.GetToken(this), ID); if (result.Success) { string content = result.Data; content = content.ReplaceHtml().Trim('"'); content = HtmlUtil.ReadHtml(Assets).Replace("#body#", content).Replace("#title#", "").Replace("#author#", "").Replace("#date#", ""); wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null); firstImgSrc = HtmlUtil.GetHtmlFirstImgUrl(content); successCallBack(); } else { AlertUtil.ToastShort(this, result.Message); } } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); AlertUtil.ToastShort(this, ex.Message); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here btn_exitLogin = FindViewById <Button>(Resource.Id.btn_exitLogin); SetToolBarNavBack(); StatusBarUtil.SetColorStatusBars(this); SetToolBarTitle(Resources.GetString(Resource.String.setting)); UpdateViewStatus(); btn_exitLogin.Click += (s, e) => { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("提示") .SetMessage("你确定退出当前账号?") .SetPositiveButton("确定", (s1, e1) => { //UserBlogShared.SetUserBlog(); UserUtil.Instance(this).Logout(); MobclickAgent.OnProfileSignOff(); UpdateViewStatus(); //AlertUtil.ToastLong(this,"成功"); }) .SetNegativeButton("取消", (s1, e1) => { return; }); alertDialog.Create().Show(); }; }
/// <summary> /// 保存错误信息到文件中 /// </summary> /// <param name="ex"></param> private void SaveCrashInfo2File(Throwable ex) { var sb = new System.Text.StringBuilder(); foreach (var(key, value) in infos) { sb.AppendLine($"{key} = {value}"); } using var writer = new StringWriter(); using var printWriter = new PrintWriter(writer); ex.PrintStackTrace(printWriter); var cause = ex.Cause; while (cause != null) { cause.PrintStackTrace(printWriter); cause = cause.Cause; } var result = writer.ToString(); sb.AppendLine(result); LoggerFactory.Current.Create().LogError(sb.ToString()); MobclickAgent.ReportError(_context, sb.ToString()); }
async void GetClientStatus(int id) { try { status = await SQLiteUtil.SelectStatus(id); if (status != null) { tv_userDisplayName.Text = status.UserDisplayName; tv_dateAdded.Text = status.DateAdded.ToCommonString(); tv_content.Text = status.Content; if (!status.UserIconUrl.Substring(status.UserIconUrl.Length - 4, 4).Contains(".png")) { iv_userIcon.SetImageResource(Resource.Drawable.noavatar); } else { ImageLoader.Instance.DisplayImage(status.UserIconUrl, iv_userIcon, options); } } } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); } }
public override bool ShouldOverrideUrlLoading(WebView view, string url) { if (url.IndexOf(Constact.Callback) > -1) { Uri uri = new Uri(url.Replace("#", "?")); var query = uri.Query.TrimStart('?').Split('&'); foreach (var item in query) { var q = item.Split('='); if (q[0] == "code") { var code = q[1]; System.Diagnostics.Debug.Write(code); Token token = AccessTokenUtil.GetToken(context); AuthorizationRequest.Authorization_Code(token, code, (userToken) => { System.Diagnostics.Debug.Write(userToken.access_token); UserTokenUtil.SaveToken(userToken, context); // ActivityCompat.FinishAfterTransition(context); context.StartActivity(new Intent(context, typeof(MainActivity))); MobclickAgent.OnProfileSignIn(code); }, error => { MobclickAgent.ReportError(context, "µÇ¼ʧ°Ü" + error); System.Diagnostics.Debug.Write(error); }); } } // view.stoploading(); } return(base.ShouldOverrideUrlLoading(view, url)); }
async void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs ex) { await Task.Run(() => { Looper.Prepare(); Toast.MakeText(this, Resources.GetString(Resource.String.search), ToastLength.Long).Show(); Looper.Loop(); }); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("生产厂商\n"); sb.Append(Build.Manufacturer).Append("\n\n"); sb.Append("手机型号\n"); sb.Append(Build.Model).Append("\n\n"); sb.Append("系统版本\n"); sb.Append(Build.VERSION.Release).Append("\n\n"); sb.Append("异常时间\n"); sb.Append(DateTime.Now.ToString()).Append("\n\n"); sb.Append("异常信息\n"); sb.Append(ex.Exception).Append("\n"); sb.Append(ex.Exception.Message).Append("\n"); sb.Append(ex.Exception.StackTrace).Append("\n\n"); MobclickAgent.ReportError(this, sb.ToString()); System.Threading.Thread.Sleep(2000); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); Java.Lang.JavaSystem.Exit(1); }
private async Task <List <ArticleCommentModel> > listArticleCommentServer() { try { var token = UserTokenUtil.GetToken(this); var result = await ArticleService.ListArticleComment(token, blogApp, postId, pageIndex); if (result.Success) { _swipeRefreshLayout.Refreshing = false; await SQLiteUtil.UpdateArticlecommentList(result.Data); return(result.Data); } else { return(null); } } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); System.Diagnostics.Debug.Write(ex.ToString()); return(null); } }
void Start() { #if UNITY_IPHONE //ReportPolicy //REALTIME = 0, //send log when log created //BATCH = 1, //send log when app launch //SENDDAILY = 4, //send log every day's first launch //SENDWIFIONLY = 5 //send log when wifi connected MobclickAgent.StartWithAppKeyAndReportPolicyAndChannelId(GetUmengAppKey(), 0, GetUmengChannel()); MobclickAgent.SetAppVersion("1.0"); MobclickAgent.SetLogSendInterval(20); JsonData eventAttributes = new JsonData(); eventAttributes["username"] = "******"; eventAttributes["company"] = "Umeng Inc."; MobclickAgent.EventWithAttributes("GameState", JsonMapper.ToJson(eventAttributes)); MobclickAgent.SetLogEnabled(true); MobclickAgent.SetCrashReportEnabled(true); MobclickAgent.CheckUpdate(); MobclickAgent.UpdateOnlineConfig(); MobclickAgent.Event("GameState"); MobclickAgent.BeginEventWithLabel("New-GameState", "identifierID"); MobclickAgent.EndEventWithLabel("New-GameState", "identifierID"); #elif UNITY_ANDROID MobclickAgent.setLogEnabled(true); MobclickAgent.onResume(); // Android: can't call onEvent just before onResume is called, 'can't call onEvent before session is initialized' will be print in eclipse logcat // Android: call MobclickAgent.onPause(); when Application exit. #endif }
public override void OnPause() { base.OnPause(); if (Config.UMengIsOpen) { MobclickAgent.OnPageEnd(CurrActivity.Title); MobclickAgent.OnPause(CurrActivity.BaseContext); } }
protected override void OnResume() { base.OnResume(); if (Config.UMengIsOpen) { MobclickAgent.OnPageStart(CurrActivity.Title); MobclickAgent.OnResume(CurrActivity.BaseContext); } }
protected override void OnPause() { base.OnPause(); if (Config.UMengIsOpen) { MobclickAgent.OnPageEnd(this.Title); MobclickAgent.OnPause(this); } }
protected override void OnResume() { base.OnResume(); if (Config.UMengIsOpen) { MobclickAgent.OnPageStart(this.Title); MobclickAgent.OnResume(this); } }
protected override void OnCreate(Bundle bundle) { Action <View> t = OnButtonClick; base.OnCreate(bundle); SetContentView(Resource.Layout.umeng_example_analytics); _context = this; MobclickAgent.SetDebugMode(true); }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); try { this.HasOptionsMenu = true; swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); swipeRefreshLayout.SetOnRefreshListener(this); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); var manager = new LinearLayoutManager(this.Activity); recyclerView.SetLayoutManager(manager); adapter = new StatusAdapter(); adapter.SetOnLoadMoreListener(this); adapter.OnDeleteClickListener = this; adapter.User = await SQLiteUtils.Instance().QueryUser(); recyclerView.SetAdapter(adapter); nologinView = this.Activity.LayoutInflater.Inflate(Resource.Layout.nologin_view, (ViewGroup)recyclerView.Parent, false); nologinView.Click += delegate(object sender, EventArgs e) { StartActivityForResult(new Intent(this.Activity, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode); }; notDataView = this.Activity.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false); notDataView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; errorView = this.Activity.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false); errorView.Click += delegate(object sender, EventArgs e) { OnRefresh(); }; recyclerView.Post(async() => { if (position == 0) { await statusesPresenter.GetClientStatus(); } else if (!LoginUtils.Instance(this.Activity).GetLoginStatus()) { recyclerView.Post(() => { adapter.SetEmptyView(nologinView); }); } }); } catch (Exception ex) { MobclickAgent.ReportError(Context, ex.Message + ex.StackTrace); } }
public async Task <ResultMessage> GetAsyn(string url) { Request request = new Request.Builder().Url(url).Build(); Response response = await okHttpClient.NewCall(request).ExecuteAsync(); var body = await response.Body().StringAsync(); var code = response.Code(); switch (code) { case (int)System.Net.HttpStatusCode.OK: return(new ResultMessage() { IsError = false, Message = body }); case (int)System.Net.HttpStatusCode.NotFound: MobclickAgent.ReportError(Context, body); return(new ResultMessage() { IsError = true, Message = "404 NotFound" }); case (int)System.Net.HttpStatusCode.Unauthorized: MobclickAgent.ReportError(Context, body); return(new ResultMessage() { IsError = true, Message = "401 Unauthorized" }); case (int)System.Net.HttpStatusCode.InternalServerError: MobclickAgent.ReportError(Context, body); return(new ResultMessage() { IsError = true, Message = "500 InternalServerError" }); case (int)System.Net.HttpStatusCode.BadGateway: MobclickAgent.ReportError(Context, body); return(new ResultMessage() { IsError = true, Message = "502 BadGateway" }); default: MobclickAgent.ReportError(Context, body); return(new ResultMessage() { IsError = true, Message = "网络链接不可用 ,请稍后再试" }); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); //初始化友盟 //MobclickAgent.SetSessionContinueMillis(300 * 1000); MobclickAgent.UpdateOnlineConfig(this.ApplicationContext); MobclickAgent.SetDebugMode(true); Button button = FindViewById <Button>(Resource.Id.MyButton); button.Click += delegate { this.StartActivity(typeof(Activity1)); }; }
public override bool ShouldOverrideUrlLoading(WebView view, string url) { try { Intent intent = new Intent(Intent.ActionView); intent.SetData(Android.Net.Uri.Parse(url)); context.StartActivity(intent); } catch (Exception ex) { MobclickAgent.ReportError(context, ex.Message); Toast.MakeText(context, "系统中没有安装浏览器客户端", ToastLength.Short).Show(); } return(true); }
async void GetClientQuestion(int id) { try { bool isSearch = Intent.GetBooleanExtra("issearch", false); if (!isSearch) { question = await SQLiteUtil.SelectQuestion(id); } BindView(); } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); } }
private async Task listSearchService(Action <List <ZzkDocumentViewModel> > successCallBack) { var result = await ZzkService.List(UserTokenUtil.GetToken(this), pageIndex, category, keyword); if (result.Success) { try { successCallBack(result.Data); } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); System.Diagnostics.Debug.Write(ex.ToString()); } } }
async void GetServerQuestion() { try { var result = await QuestionService.GetQuestionDetail(AccessTokenUtil.GetToken(this), questionId); if (result.Success) { question = result.Data; BindView(); } } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); } }
private void Hook() { AlertDialog.Builder builder = new AlertDialog.Builder(_context); builder.SetPositiveButton("退出应用", (e, s) => { MobclickAgent.OnKillProcess(_context); int pid = Process.MyPid(); Process.KillProcess(pid); }); builder.SetNeutralButton("退出", (e, s) => { Finish(); }); builder.SetNegativeButton("取消", (e, s) => { }); builder.Show(); }
public override void OnCreate() { base.OnCreate(); MobclickAgent.SetDebugMode(true); MobclickAgent.OpenActivityDurationTrack(false); MobclickAgent.SetScenarioType(this, MobclickAgent.EScenarioType.EUmNormal); OkHttpUtils.Context = this; SQLiteUtils.Instance(); PlatformConfig.SetWeixin("wxcf8f642a8aa4c630", "76ebc29b4194164aee32eedff2e17900"); PlatformConfig.SetSinaWeibo("1422675167", "02975c36afd93d3ae983f8da9e596b86", "https://api.weibo.com/oauth2/default.html"); if (!BuildConfig.Debug) { AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; } }
/**************** * * 发起添加群流程。群号:xamarin android,C#,Web前端(371026625) 的 key 为: Q90lFEYkStricLdyCyJQMzJJq_5bo7gb * 调用 joinQQGroup(Q90lFEYkStricLdyCyJQMzJJq_5bo7gb) 即可发起手Q客户端申请加群 xamarin android,C#,Web前端(371026625) * * @param key 由官网生成的key * @return 返回true表示呼起手Q成功,返回fals表示呼起失败 ******************/ public bool joinQQGroup(string key) { Intent intent = new Intent(); intent.SetData(Android.Net.Uri.Parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key)); // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) try { StartActivity(intent); return(true); } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); System.Diagnostics.Debug.Write(ex.ToString()); // 未安装手Q或安装的版本不支持 return(false); } }
private void BindScripts() { ApiCaller ac = gameObject.GetComponent <ApiCaller>(); if (ac == null) { gameObject.AddComponent("ApiCaller"); } MobclickAgent ma = gameObject.GetComponent <MobclickAgent>(); if (ma == null) { gameObject.AddComponent("MobclickAgent"); } if (!Application.isEditor) { InitInEditMode comp = gameObject.GetComponent <InitInEditMode>(); Destroy(comp); } }
public override void OnCreate() { base.OnCreate(); ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).WriteDebugLogs().Build(); ImageLoader.Instance.Init(configuration);//初始化图片加载框架 Config.Debug = true; SQLiteUtil.Instance(); MobclickAgent.SetDebugMode(true);//开启调试模式,如果不开启则不会上传umeng统计 MobclickAgent.OpenActivityDurationTrack(false); MobclickAgent.SetScenarioType(this, MobclickAgent.EScenarioType.EUmNormal); PlatformConfig.SetWeixin("wx633888643fbae319", "5034ad765b2ba64dec7ed7c6618581fb"); PlatformConfig.SetSinaWeibo("1422675167", "02975c36afd93d3ae983f8da9e596b86", "https://api.weibo.com/oauth2/default.html"); PlatformConfig.SetQQZone("100424468", "c7394704798a158208a74ab60104f0ba"); if (!BuildConfig.Debug) { AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; } activities = new List <Activity>(); }
async void GetNewsContent(Action callBack) { try { if (string.IsNullOrEmpty(news.Body)) { var result = await HttpClient.NewsService.GetNewsDetail(AccessTokenUtil.GetToken(this), ID); if (result.Success) { news.Body = result.Data; await SQLiteUtil.UpdateNews(news); firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(news.Body); news.Body = news.Body.ReplaceHtml().Trim('"'); string content = HtmlUtil.ReadHtml(Assets).Replace("#body#", news.Body).Replace("#title#", news.Title).Replace("#author#", "").Replace("#date#", "发布日期:" + news.DateAdded.ToString("yyyy年MM月dd日 HH:mm")); wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null); callBack(); } else { AlertUtil.ToastShort(this, result.Message); callBack(); } } else { news.Body = news.Body.ReplaceHtml().Trim('"'); string content = HtmlUtil.ReadHtml(Assets).Replace("#body#", news.Body).Replace("#title#", news.Title).Replace("#author#", "").Replace("#date#", "发布日期:" + news.DateAdded.ToString("yyyy年MM月dd日 HH:mm")); wb_content.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null); firstImgUrl = HtmlUtil.GetHtmlFirstImgUrl(news.Body); callBack(); } } catch (Exception ex) { AlertUtil.ToastShort(this, ex.ToString()); callBack(); MobclickAgent.ReportError(this, ex.ToString()); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); mainPresenter = new MainPresenter(this); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); fm = SupportFragmentManager; bottomBar = BottomBar.Attach(this, bundle); bottomBar.UseFixedMode(); bottomBar.SetItems(Resource.Menu.bottombar_menu); bottomBar.SetOnMenuTabClickListener(this); MobclickAgent.SetDebugMode(true); MobclickAgent.OpenActivityDurationTrack(false); MobclickAgent.SetScenarioType(this, MobclickAgent.EScenarioType.EUmNormal); }
private async Task <List <BookmarksModel> > listBookmarkServer() { var result = await BookmarksService.List(UserTokenUtil.GetToken(this), Constact.PageSize, pageIndex); if (result.Success) { _swipeRefreshLayout.Refreshing = false; //bookMarkList = result.Data; try { await SQLiteUtil.UpdateBookMarkList(result.Data); return(result.Data); } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); System.Diagnostics.Debug.Write(ex.ToString()); return(null); } } return(null); }