플레이를 Google에,하지만 난, 알림 bulider에 약간의 충돌을 얻을이 충돌 메시지
java.lang.NoClassDefFoundError: android.app.Notification$Builder
이 내 알림 생성 코드,
public void CreateNtf(String text)
{
Notification notificationView;
PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this,0,getIntent(),Intent.FLAG_ACTIVITY_NEW_TASK);
if(Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 15){
notificationView = new Notification.Builder(context)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(text)
//.setTicker(getResources().getString(R.string.app_name) + " " + text)
.setWhen(System.currentTimeMillis())
.setContentIntent(pendingIntent)
//.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(false)
.setSmallIcon(R.drawable.ic_launcher)
.getNotification();
}else{
notificationView = new Notification.Builder(context)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(text)
//.setTicker(getResources().getString(R.string.app_name) + " " + text)
.setWhen(System.currentTimeMillis())
.setContentIntent(pendingIntent)
//.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(false)
.setSmallIcon(R.drawable.ic_launcher)
.build();
}
notificationView.flags |= Notification.FLAG_NO_CLEAR;
notificationView.flags |= Notification.FLAG_ONGOING_EVENT;
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notificationView);
}
그래서이 문제를 해결할 수 있습니까? 난 여전히 나를 위해 일한, 구글의 오류와 충돌
이 때문에 지원 패키지 문제로의
명백히 Notification.Builder를 if 블록 외부에 선언하고있는 것입니다. – njzk2