마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

notification에서 app 실행하는 코드인데..

0 추천
		TimerTask task_fv = new TimerTask() {
			public void run() {
					try {
					NotificationCompat.Builder builder = new NotificationCompat.Builder(
							mContext);
					builder.setSmallIcon(R.drawable.ic_launcher)
							.setTicker(mContext.getString(R.string.start_fv_notification))
							.setAutoCancel(false); // 알림바에서 자동 삭제
					noti_dm = builder.build();
					
					
					RemoteViews views = new RemoteViews(getApplicationContext()
							.getPackageName(), R.layout.fv_layout_one);

					PendingIntent contentIntent = PendingIntent.getActivity(
							getApplicationContext(), 0, new Intent(
									getApplicationContext(),
									Configuration_Activity.class), 0);
					
					PendingIntent pending_app01 = PendingIntent.getActivity(
							mContext, 0, new Intent(mContext
									.getPackageManager()
									.getLaunchIntentForPackage(app01_pack)), 0);
					
					views.setOnClickPendingIntent(R.id.app01, pending_app01);

					views.setImageViewBitmap(R.id.app01,
							getAppIconResource(app01_pack));

					noti_dm.contentIntent = contentIntent;
					noti_dm.contentView = views;
					noti_dm.flags |= Notification.FLAG_ONGOING_EVENT;
					notificationManager.notify(1114, noti_dm);

					// Thread.sleep(1000);
				} catch (Exception e) {
					Log.e(TAG, e.toString());
				}
			}
		};

 

 

자꾸 nullpointerException이 나서요..
어디가 잘못되었을까요? ㅜㅜ..

bluehong (620 포인트) 님이 2013년 9월 30일 질문
bluehong님이 2013년 9월 30일 수정
09-30 15:47:22.472: E/AndroidRuntime(15952): FATAL EXCEPTION: Timer-0
09-30 15:47:22.472: E/AndroidRuntime(15952): java.lang.NullPointerException
09-30 15:47:22.472: E/AndroidRuntime(15952):     at summarizer.service.RunNotification$2.run(RunNotification.java:156)
09-30 15:47:22.472: E/AndroidRuntime(15952):     at java.util.Timer$TimerImpl.run(Timer.java:284)

여기서 에러가 나네요..
notificationManager.notify(1114, noti_dm);

이전엔 null이 안잡히는데 왜그런걸까요?ㅠ

2개의 답변

0 추천
에러가나면 에러로그를 주셔야 ㅡㅡㅋ
건방진프로그래머 (26,630 포인트) 님이 2013년 9월 30일 답변
09-30 15:47:22.472: E/AndroidRuntime(15952): FATAL EXCEPTION: Timer-0
09-30 15:47:22.472: E/AndroidRuntime(15952): java.lang.NullPointerException
09-30 15:47:22.472: E/AndroidRuntime(15952):     at summarizer.service.RunNotification$2.run(RunNotification.java:156)
09-30 15:47:22.472: E/AndroidRuntime(15952):     at java.util.Timer$TimerImpl.run(Timer.java:284)

여기서 에러가 나네요..
notificationManager.notify(1114, noti_dm);

이전엔 null이 안잡히는데 왜그런걸까요?ㅠ
아 현재 코드는 try 양끝에 Looper.prepare Looper.loop를 추가해두었습니다.
0 추천
notificationManager 가 null 인 것 같은데요.
익명사용자 님이 2013년 9월 30일 답변
...