Android L から android.app.Notification.Builder.setVisibility() を使用すると問題が発生します。Android Studio をベータ版に更新し、L SDK をダウンロードして、compileSdkVersion と targetSdkVersion を 20 に設定しました。しかし、Android Studio は引き続き使用できます。 setVisibility メソッドを解決します。
(編集: 以下のコメントに基づいて compileSdkVersion と targetSdkVersion を更新し、サポート ライブラリを 20.+ から 21.+ に更新しました)
setVisibility() 行がなければ、私のコードはコンパイルして実行されます。代わりに NotificationCompat.Builder を試すと、同じエラーが発生します。
これを修正する方法を知っている人はいますか?
android {
compileSdkVersion 'android-L' // was 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 13
targetSdkVersion 'L' // was 20
...
...
compile 'com.android.support:support-v13:21.+'
compile 'com.android.support:appcompat-v7:21.+'
import android.app.Notification;
...
noti = new Notification.Builder(InfoPanel.getContext())
.setContentTitle(notiTitle)
.setContentText("text")
.setSmallIcon(notifyIcon)
.setOngoing(true)
.addAction(firstActionIcon, firstActionText, firstActionPI)
.addAction(R.drawable.optionsmenuicon, InfoPanel.getContext().getString(R.string.options), piOptions)
.addAction(R.drawable.exit, InfoPanel.getContext().getString(R.string.remove), piExitNotification)
.setContentIntent(upperPendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
.setVisibility(VISIBILITY_PUBLIC)
.build() ;
「メソッド 'setVisibility(?)' を解決できません」および「シンボル 'VISIBILITY_PUBLIC' を解決できません」という IDE エラーが表示されます。
編集: compileSdkVersion を更新した後、最初の Gradle ビルド エラー「メソッド 'setVisibility(?)' を解決できません」はなくなりましたが、IDE ではまだ赤で表示されます。2 番目のエラーはまだ両方の場所にあります。