2017-04-06 8 views
0

특정 신호가 감지 될 때 잠긴 화면에 알림이 표시되는 알림 메서드를 작성하려고합니다. 기호 클래스를 찾을 수 없습니다. NotificationManagerCompat

public void showNotification(Beacon beacon) { 

    Resources r = getResources(); 
    int random = (int)System.currentTimeMillis(); 
    Notification notification = new NotificationCompat.Builder(this) 
      .setSmallIcon(android.R.drawable.ic_popup_reminder) 
      .setContentTitle("Beacons Found") 
      .setContentText(beacon.getID().toString()) 
      .setVisibility(0) // allow notification to appear on locked screen 
      .setAutoCancel(true) 
      .build(); 

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    notificationManager.notify(random, notification); 

} 

내가 위의 코드를 가지고,하지만 난 그것을 실행할 때 말한다 "변수 SetVisibility 기호를 찾을 수 없습니다"나의 이해는 내가 다음 코드 (0) .setVisibility을 포함 할 필요가 있다는 것입니다. 나는 온라인으로 어떤 연구를하고 내가이 가져와야 할 것 같다

import android.support.v4.app.NotificationManagerCompat; 

을하지만이 import 문을 포함 할 경우, 그것은

어떻게해야합니까에게 "NotificationManagerCompat 심볼 클래스를 찾을 수 없습니다"말할 것? 이미 프로젝트에 새 모듈을 추가하기 때문에

답변

0

어쩌면 당신이이 오류가, 올 안드로이드 지원 저장소 SDK를 설치하고 프로젝트의 libs와 폴더에 "안드로이드 지원-v4.jar을 가지고있다.

변화 minSdkVersion, targetSdkVersion, buildToolsVersion, 그것을 해결하기 위해, 그리고 compileSdkVersion는 원래 모듈에 build.gradle하였습니다.

을 그 falseminifyEnabled을 설정 한 후.

을 무엇 실제로 사용 (안드로이드 스튜디오 3.0.1를 사용하는 동안) Y는 또 다른 libs와 및 종속성과 빌드 파일을 확인

compile 'com.facebook.android:facebook-android-sdk:4.26.0' 

에 페이스 북을 설정 나를 위해 그것을 한 고정.

내 현재 빌드 파일 :

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "http://repo1.maven.org/maven2" 
     } 
     // maven { 
     // url 'https://maven.google.com' 
     // } 
     // since Android Studio 3.0.0 
     // or google() 
     flatDir { 
      dirs 'libs' 
     } 
    } 
} 
관련 문제