app上线后,后期维护显得尤为重要,今天给大家分享一下app上线后出现bug后的解决方法

1.继承Application类,重写onCreate方法

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.lang.Thread.UncaughtExceptionHandler;

import android.app.Application;

/**
 * App上线后 bug的处理
 *
 */
public class MyApplication extends Application {

	@Override
	public void onCreate() {
		super.onCreate();
		System.out.println("application启动了....");
		//捕获异常
		Thread.currentThread().setUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
	}
	private class MyUncaughtExceptionHandler implements UncaughtExceptionHandler {
		//当有未捕获的异常的时候会调用
		//Throwable : 其实Exception和Errorfu父类
		@Override
		public void uncaughtException(Thread thread, Throwable ex) {
			System.out.println("哥捕获了异常");
			//将异常保存到文件中
			try {
				//异常文件log.txt,可以判断返回给我们的服务器
				ex.printStackTrace(new PrintStream(new File("/mnt/sdcard/log.txt")));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
			//保存文件之后,自杀,myPid() : 获取自己的pid
			android.os.Process.killProcess(android.os.Process.myPid());
		}

	}

}

2.AndroidManifest.xml中设置android:name=".MyApplication"属性

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
<span style="white-space:pre">	</span><activity
            android:name="com.demo.bug.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>

                <!-- MAIN : 主界面,入口界面,其实java类型的main方法 -->
                <action android:name="android.intent.action.MAIN" />
                <!-- LAUNCHER : 在桌面上释放一个图标 -->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity> ......
</application>

3.将bug.txt反馈回我们的服务器

android app上线后bug的处理的更多相关文章

  1. 转Android APP安装后不在桌面显示图标的应用场景举例和实现方法

    转http://www.cnblogs.com/allenzheng/p/4510725.html#3186608 Android APP安装后不在桌面显示图标的应用场景举例和实现方法 最近在为公司做 ...

  2. Android APP安装后不在桌面显示图标的应用场景举例和实现方法

    最近在为公司做一款车联网的产品,由于公司本身擅长于汽车解码器的研发,所以该产品的诊断功能的实现除了使用目前市面上车联网产品中大量使用的OBD协议外,还会使用一些专车专用协议去实现一些特殊的诊断功能,如 ...

  3. Android APP安装后不在桌面显示图标的应用场景

    一般情况下是由于特殊情况下,需要隐藏app的启动入口,即在launcher界面不需要显示该入口,会由其他app跳转至.怎么设置如下代码: <activity android:name=" ...

  4. android APP上线前,应该准备的东西

    这里给出一些主流的应用市场名单,有些可能已经不行了,自己找一找,很容易的: 应用市场图-1

  5. Visual Studio 2015开发Android App启动调试始终无法完成应用部署的解决方案

    创建一个Android App项目后,直接启动调试发现Visual Studio Emulator for Android已成功运行,但应用始终处于Build中(等待时间超过1小时),并未如预期通过a ...

  6. Visual Studio 2015开发Android App问题集锦

    Visual Studio 2015开发Android App 启动调试始终无法完成应用部署的解决方案 创建一个Android App项目后,直接启动调试发现Visual Studio Emulato ...

  7. Unity上线google商店 用IL2Cpp打包64位版本和Android APP Bundle优化 及产生的bug

    ios刚上线,这边着手改成android版本,我开始使用的是unity2017.4.1版本 上传谷歌商店是出现这两个警告: 要支持64位,但是在2017版本上没有找到64位的打包选项,猜测应该是版本的 ...

  8. Android开发中上线后修改应用名称的若干问题

    一.在Android Studio 1.3中修改app的包名: 需求来源: 之前开发的app已经在腾讯的应用宝上线,应客户要求,app需要改名字,这个就有点麻烦了.如果申请改名字,要求如下: 截图上图 ...

  9. 《Android Studio开发实战 从零基础到App上线》资源下载和内容勘误

    转载于:https://blog.csdn.net/aqi00/article/details/73065392 资源下载 下面是<Android Studio开发实战 从零基础到App上线&g ...

随机推荐

  1. 输入m乘法表

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. lnmp下启动mysql报错 The server quit without updating PID file

    启动时候错误代码:Starting MySQL[FAIL.] The server quit without updating PID file (/var/run/mysqld/mysqld.pid ...

  3. 解决Debian系统的Crontab执行时间时差问题

    首先用 * * * * * date >> /root/log.log 做个测试,发现显示的是UTC的时间,但是直接执行date,得到的是CST的时间.可见在Debian里crontab的 ...

  4. 从不同方面寻找bug

    从小学生的角度,为了熟能生巧,更好掌握知识,那就需要不断的练习,然而app没有重新开始的功能,要退出再重新进入,很麻烦.还有,如果小学生只想做一类的计算,例如,只想做减法或乘法,那么它就不能满足. 我 ...

  5. python 常用高效代码写法集锦

    一.打开文件 #使用 with 语句操作文件对象 with open(r'somefileName') as somefile: for line in somefile: print line # ...

  6. Centos下安装Mongodb

    转自:http://nnzhp.cn/article/10/ Mongodb是一种nosql类型的数据库,高性能.易部署.易使用的特点在IT行业非常流行. 下面介绍一下mongodb的安装方式,这里我 ...

  7. 编译安装php

    ./configure --prefix=/usr/local/php \--with-libdir=lib64 \--enable-fpm \--with-fpm-user=roter \--wit ...

  8. Oracle数据库根据时间查询

    ' and trans_dt between to_date('2010-12-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and to_date('2011-12-3 ...

  9. invoke

    在用.NET Framework框架的WinForm构建GUI程序界面时,如果要在控件的事件响应函数中改变控件的状态,例如:某个按钮上的文本原先叫“打开”,单击之后按钮上的文本显示“关闭”,初学者往往 ...

  10. 315. Count of Smaller Numbers After Self

    You are given an integer array nums and you have to return a new counts array. The counts array has ...