AI编程生活评测

Android编程遇到的小问题20150819

编程笔记 / 2015-08-18 / 1 min

问题一: Notificationbuild() 方法是在 API level 16 才有的

代码:

notification = new Notification.Builder(ctx)
                .setContentTitle("Title").setContentText("Text")
                .setSmallIcon(R.drawable.ic_launcher).build();

提示错误:

Call requires API level 16 (current min is 14): android.app.Notification.Builder#build

原因见文档:

public Notification build ()
Combine all of the options that have been set and return a new Notification object.Added in API level 16
也就是说, Notificationbuild ()方法是在 API level 16 才有的;而我的适配版本是 API level 14 ,需要使用 getNotification () 才行。

问题二:

adb 服务出现异常,如果想手工关闭 adb 服务,可以使用下面的命令:
关闭adb服务命令:adb kill-server
启动adb服务命令:adb start-server

问题三:

eclipse 下按 alt+/ 快捷键无代码提示故障: 也不知道为啥会出现这个问题,我的情况解决方法如下: Window -> Preferences -> General -> Keys 1. Restore Defaults恢复默认设置; 2. 把 word completion 的快捷键设置 alt+C ; 3. 把 Content Assist 的快捷键由 ctrl+space 改成 alt+/ ; 4. window -> Preferences -> Java -> Editor -> Content Assist -> Enable auto activation 选项要打上勾;
  1. IT疯狂女 2015-08-19 · 14:42

    Android编程遇到的小问题还真有点难搞

    1. 行星带 2015-08-21 · 10:25

      奇奇怪怪的各种问题~