0
저는 Android를 배우기 시작했는데 Java 지식은 제한적이지만 C/C++ objective C 등으로 세미 가능합니다 ... 저는 현재 Android 애플리케이션 개발이라는 p2pwrox 전자 책을 통해 작업하고 있습니다. 나는 가져 왔지만, "시도해보십시오 : 상태 표시 줄에 알림 표시"pg73에 나와 있습니다.notificationID는 변수로 해결할 수 없습니다
나는 모든 것을 다 쓸 수 있었고 안드로이드 SDK와 Eclipse IDE에 익숙해졌지만, 아래에 표시된 NotificationActivity.java 파일에이 오류가 있습니다. 수정 방법을 모르겠습니다.
package com.androidtestingfun.www;
import android.app.Activity;
import android.os.Bundle;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
public class NotificationsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.btn_displaynotif);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
displayNotification();
}
});
}
protected void displayNotification()
{
//---PendingIntent to launch activity if the user selects this notification---
Intent i = new Intent(this, NotificationView.class);
i.putExtra("notificationID", notificationID); //-----the second parameter here is getting an error
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, i, 0);
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(
R.drawable.icon,
"Reminder: Meeting starts in 5 minutes",
System.currentTimeMillis());
CharSequence from = "System Alarm";
CharSequence message = "Meeting with customer at 3pm...";
notif.setLatestEventInfo(this, from, message, pendingIntent);
//---100ms delay, vibrate for 250ms, pause for 100ms and then vibrate for 500ms---
notif.vibrate = new long[] {100, 250, 100, 500};
nm.notify(notificationID, notif);//-----the first parameter here is getting an error
}
}
내 말을들을 수있는 아이디어는 크게 높이 평가할 수 있습니다. 빌드를 청소하려고했지만 그다지 도움이되지 않습니다.
무엇 바보, 미안 그것을 분류했다 . –
btw 도움을 주셔서 감사합니다. –
문제 없습니다. 기꺼이 도와 드리겠습니다. – MByD