zoukankan      html  css  js  c++  java
  • Android 系统API兼容性崩溃问题总结

    由于使用系统Service的API,每个机型不同SDK版本对异常的处理结果各不相同,所以建议在使用系统API 多数应该优先考虑捕获系统异常,以减少崩溃。

    (1) 隐士添加账号同步,相关代码如下:

    public boolean addAccountExplicitly(Account account, String password, Bundle userdata) {
    if (account == null) throw new IllegalArgumentException("account is null");
    try {
    return mService.addAccountExplicitly(account, password, userdata);
    } catch (RemoteException e) {
    // Can happen if there was a SecurityException was thrown.
    throw new RuntimeException(e);
    }
    }

    (2)JobSchedule builder问题 ,相关代码如下:
    JobScheduler scheduler = (JobScheduler)context.getSystemService(JOB_SCHEDULER_SERVICE);
    try {
    scheduler.schedule(builder.build());
    }catch (Exception e){
    }

  • 相关阅读:
    Python之数学(math)和随机数(random)
    《图解HTTP》读书笔记
    leetcode1008
    leetcode1007
    leetcode1006
    leetcode1005
    leetcode218
    leetcode212
    leetcode149
    leetcode140
  • 原文地址:https://www.cnblogs.com/daqiang5566/p/7488359.html
Copyright © 2011-2022 走看看