登录
首页 » Android » Android捕获全局异常并写日志保存到sd卡

Android捕获全局异常并写日志保存到sd卡

于 2022-06-11 发布 文件大小:633.75 kB
0 163
下载积分: 2 下载次数: 1

代码说明:

Android捕获全局异常并写日志保存到sd卡,捕获异常消息后输出这个消息,可避免APP强制退出,抛出NullPointException玩玩哈,捕获全局异常是因为有的异常我们捕获不到,捕获时我们采用同步方法,以免单例多线程环境下出现异常,初始化,把当前对象设置成UncaughtExceptionHandler处理器,处理异常时我们还可以把异常信息写入文件,以供后来分析。   保存错误信息到文件中 返回文件名称,我们定义了saveCrashInfo2File(Throwable ex)方法,便于将文件传送到服务器,并保存信息到SD卡中。

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • android 播放网络MP3 音乐播放
    简单的基本功能,实测可行。 核心代码:package com.sharpandroid.music.activity;import java.io.IOException;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.ImageButton;import android.widget.SeekBar;import android.widget.TextView;import com.sharpandroid.music.R;import com.sharpandroid.music.StreamingMediaPlayer;public class MediaPlayer extends Activity { private Button streamButton; private ImageButton playButton; private boolean isPlaying; private TextView playTime; private StreamingMediaPlayer audioStreamer; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); initControls(); } private void initControls() { playTime=(TextView) findViewById(R.id.playTime); streamButton = (Button) findViewById(R.id.button_stream); streamButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startStreamingAudio(); }}); playButton = (ImageButton) findViewById(R.id.button_play); playButton.setEnabled(false); playButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (audioStreamer.getMediaPlayer().isPlaying()) { audioStreamer.getMediaPlayer().pause(); playButton.setImageResource(R.drawable.button_play); } else { audioStreamer.getMediaPlayer().start(); audioStreamer.startPlayProgressUpdater(); playButton.setImageResource(R.drawable.button_pause); } isPlaying = !isPlaying; }}); } private void startStreamingAudio() { try { final SeekBar progressBar = (SeekBar) findViewById(R.id.progress_bar); if ( audioStreamer != null) { audioStreamer.interrupt(); } audioStreamer = new StreamingMediaPlayer(this, playButton, streamButton, progressBar,playTime); audioStreamer.startStreaming("http://192.168.64.1/xa.mp3",5208, 216); streamButton.setEnabled(false); } catch (IOException e) { Log.e(getClass().getName(), "读取音乐出错!", e); } }}
    2014-05-26下载
    积分:1
  • 临近提醒
    临近提醒,比如到达某一位置进行提醒临近提醒,比如到达某一位置进行提醒临近提醒,比如到达某一位置进行提醒临近提醒,比如到达某一位置进行提醒临近提醒,比如到达某一位置进行提醒
    2022-04-13 10:28:42下载
    积分:1
  • 课程表源码
    android课程表开发学习,不是很完善,但是涉及道了,几个新手不易知道的知识点。
    2022-09-06 16:00:02下载
    积分:1
  • 移动GPS定位
    利用androids studio2.1平台,实现获取经纬度坐标和海拔高度
    2022-08-26 12:30:24下载
    积分:1
  • 安卓蓝牙
    此程序是 android 设备中使用蓝牙的例子 /* Arduino-安卓系统-Bluetoooth,一个简单的蓝牙套接字与 android 系统的通信 版权所有 2013年布兰登 · 汤姆斯 权限是特此授予,免费的向任何人索取这份 这个软件和相关的文档文件 ("软件") 来处理的 在软件中不受限制,包括不受限制的权利 以使用、 复制、 修改、 合并、 发布、 分发、 再许可或卖 将复制的软件,并允许该软件是谁的人 装备这样做,符合以下条件: 上面的版权声明和本许可声明应包括在 所有副本或软件的重要部分。
    2023-05-24 17:05:04下载
    积分:1
  • mvp模式之登录demo
    对于MVP(Model View Presenter),大多数人都能说出一二:“MVC的演化版本”,“让Model和View完全解耦”等等。本篇博文仅是为了做下记录,提出一些自己的看法,和帮助大家如何针对一个Activity页面去编写针对MVP风格的代码。从简单的demo了解认识mvp。
    2022-02-14 17:22:38下载
    积分:1
  • Code01
    实现了一个简单的安卓应用程序,适用于安卓开发入门(Implement a simple Android application for Android development starters)
    2020-06-19 23:20:01下载
    积分:1
  • MXMagneticfield
    从手机采集加速度,陀螺仪,地磁 传感器数据并实时显示( U4ECE u624B u673A u91C7 u96C6 u52A0 u901F u5EA6 uFF0C u9640 u87A u7H)
    2017-05-03 10:36:03下载
    积分:1
  • gomoku-master
    android game The name "Gomoku" is from the Japanese language, in which it is referred to as gomokunarabe . Go means five, moku is a counter word for pieces and narabe means line-up. The game is also popular in Korea, where it is called omok which has the same structure and origin as the Japanese name. It is said to have originated in China with the name Wu Zi Qi . In the nineteenth century, the game was introduced to Britain where it was known as Go Bang, said to be a corruption of the Japanese word goban, said to be adopted from Chinese k i pan chess-board.
    2014-03-22 16:20:19下载
    积分:1
  • location_jiankong
    android 位置监控,让别人可以得到自己的位置,也可以自己查看地图(android position monitoring, so that others can get their own location, you can see for yourself map)
    2013-08-31 17:33:55下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载