APP开发流程实例讲解-儒释道网络电台八天开发全程-百度云深度兼容测试并进一步优化排错

APP开发流程实例讲解-儒释道网络电台八天开发全程之

百度云深度兼容测试并进一步优化排错

APP开发流程实例讲解-儒释道网络电台八天开发全程

  1. 项目发起
  2. 功能和界面初步设定
  3. 在Android Studio中完成界面设计
  4. 实现功能代码:播放控制
  5. 优化排错:增强稳定性和添加异常处理
  6. 界面美化并进一步优化排错
  7. 百度云深度兼容测试并进一步优化排错
  8. 签名发布

加入Log

测试前的准备,必须添加Log。添加Log是个非常好的编程习惯。在开发阶段,单步调试也不错。但在测试阶段,必须使用Log。添加一个Log的控制类(网上找来的)

/**
 * Created by do168 on 16-7-9.
 * Log.v() Log.d() Log.i() Log.w() 以及 Log.e() 。
 * 根据首字母对应VERBOSE,DEBUG,INFO, WARN,ERROR
 *
 public static final int ASSERT = 7;
 public static final int DEBUG = 3;
 public static final int ERROR = 6;
 public static final int INFO = 4;
 public static final int VERBOSE = 2;
 public static final int WARN = 5;
 */
public class MyLog {
    public static int logLevel = Log.VERBOSE;

    public static void i(String tag, String msg) {
        if (logLevel <= Log.INFO)
            android.util.Log.i(tag, msg);
    }

    public static void e(String tag, String msg) {
        if (logLevel <= Log.ERROR)
            android.util.Log.e(tag, msg);
    }

    public static void d(String tag, String msg) {
        if (logLevel <= Log.DEBUG)
            android.util.Log.d(tag, msg);
    }

    public static void v(String tag, String msg) {
        if (logLevel <= Log.VERBOSE)
            android.util.Log.v(tag, msg);
    }

    public static void w(String tag, String msg) {
        if (logLevel <= Log.WARN)
            android.util.Log.w(tag, msg);
    }
}

使用也非常简单,在程序出错或需要记录信息的地方用上面的法就可以了。主要在WebApi中和VideoView错误输出时记录

    public void GetNote(IStringEvent noteEvent) {
        this.noteEvent = noteEvent;
        noteLoadTimes = 0;
        Request request = new Request.Builder()
                .url(noteUrl)
                .build();

        client.newCall(request).enqueue(new Callback() {

            @Override
            public void onFailure(Call call, IOException e) {
                MyLog.e("GetNote onFailure", e.getMessage());
                e.printStackTrace();
                if(e.getCause().equals(SocketTimeoutException.class) && noteLoadTimes<maxLoadTimes)
                {
                    noteLoadTimes++;
                    MyLog.w("GetNote onFailure", "e.getCause().equals(SocketTimeoutException.class) && noteLoadTimes<maxLoadTimes");
                    client.newCall(call.request()).enqueue(this);

                } else {
                    WebApi.this.noteEvent.getMsg(null);
                }
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String html = new String(response.body().bytes(), "utf8");
                Matcher m = noteItemPattern.matcher(html);
                StringBuilder sb = new StringBuilder();
                while (m.find()){
                    String nm = m.group(1);
                    if(nm.startsWith("<")) {
                        Matcher hm = htmlTagPattern.matcher(nm);
                        nm = hm.replaceAll("");
                    }
                    sb.append(nm).append("\r\n");
                }
                if(sb.length()==0)
                    MyLog.w("GetNote onResponse", html);

                WebApi.this.noteEvent.getMsg(sb.toString());
            }
        });
    }
VideoView错误输出时记录
        videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
                MyLog.e("MediaPlayer onError", "int what "+what+", int extra"+extra);
                resetVideoView(false);
                return false;
            }
        });

修正几个错误

经自己手工测试,发现了几个问题,加以修正

1、更新ListView :((ServerListAdapter)lv_servers.getAdapter()).notifyDataSetChanged();

2、失去焦点的处理

    @Override
    protected void onStop() {
        MyLog.v("onStop", "程序关闭,关闭视频。");
        resetVideoView(false);
        super.onStop();
    }
3、增加网络返回值返回NULL的检测

4、添加检测是否仅声音函数,替换变量

boolean isOnlySound(){return cb_onlySound.isChecked();}

使用百度云深度兼容测试

百度云深度兼容测试首次使用免费,每天前50名免费。测试用时约3分钟。

测试过程:注册登陆、上传APP、选择服务、等待约10分钟、查看结果

测试结果最热门的前50种机型中通过46种,有4种出问题。结果如下图:

百度云深度兼容测试

问题列表

问题类型出错定位发生机型数问题机型
crash java.lang.RuntimeException2
anr Input dispatching timed out (Waiting because the touched window has not finished processing the input even...2
我看了半天,换我现在的水平,没看出原因来 尴尬

测试出来的内容主要有:结果综述、兼容报告、性能报告、终端列表

下面是百度云 深度兼容测试结果
链接地址:https://console.bce.baidu.com/aat/report/share/t/181596
提取密码:PMqD
我看了半天没看出问题出在哪里,哪位功夫深的,帮忙给看一下。


今天的工作就到这里吧。


源码地址 https://code.csdn.net/do168/buddhismnetworkradio




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值