幼稚な質問かもしれませんが、私は初心者ですので、間違った質問だと思わないでください。
、私はたくさん検索していました。また、このhttp://developer.android.com/guide/topics/ui/notifiers/notifications.htmlチュートリアルに従っています。また、グーグルで問題を解決しましたが、見つかりませんでした。
これは私の課題です。
メインアクティビティにEditTextとボタンがあります。ボタンをクリックすると通知が生成され、その通知を開くと別のアクティビティが開いており、EditTextを介してメインアクティビティに入力したEditextデータが表示されます。
私の質問は....
http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updatingのように、保留中の通知の数を単一の通知ウィンドウに表示したいのですが、 これを理解できませんでした -->開始データを処理してからユーザーに通知するループの.... どうすればこれを実現できますか。データを処理して保留中のカウントを取得するにはどうすればよいですか。通知がない場合、このカウントは減少することに注意してください???
When click a notification than i want to get all notifications in a separate activity just like a messages in inbox.
e.g. in my main activity i am clicking the button 10 times, so actually 10 notifications will generate in a single notification window with count=10, but it shows count = 1?? when i open the notifications than it will only show the latest notification contents in another activity, how can i show remaining 9 in a single activity??
Below in my Main activity....
Button btn;
EditText edtText;
NotificationCompat.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
edtText = (EditText) findViewById(R.id.editText);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CreteNotification(Calendar.getInstance().getTimeInMillis(), edtText.getText().toString());
}
});
}
protected void CreteNotification(long when, String data) {
String notificationContent ="Notification Content Click Here to go more details";
String notificationTitle ="This is Notification";
int number = 1;
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
int smalIcon =R.drawable.ic_launcher;
String notificationData = data;
Intent intent = new Intent(getApplicationContext(), MyNotificationClass.class);
intent.putExtra("Message", notificationData);
intent.putExtra("Time", Integer.toString((int) when) );
intent.setData(Uri.parse("content://"+when));
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager notificationManager =(NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setWhen(when)
.setContentText(notificationContent)
.setContentTitle(notificationTitle)
.setSmallIcon(smalIcon)
.setAutoCancel(true)
.setTicker(notificationTitle)
.setLargeIcon(largeIcon)
.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND)
.setContentIntent(pendingIntent);
// Start of a loop that processes data and then notifies the user
// how to loop??????????????????
notificationBuilder.setNumber(++number);
Notification notification = notificationBuilder.getNotification();
notificationManager.notify(1, notification);
}
code where i want to show all notifications?????
HashMap<String, String> inboxMsg;
TextView notiTextView;
Button btn;
int Id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_notification_class);
inboxMsg = new HashMap<String, String>();
Id = 0;
notiTextView = (TextView) findViewById(R.id.textView1);
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@SuppressWarnings("rawtypes")
@Override
public void onClick(View v) {
Set<String> keys = inboxMsg.keySet();
Iterator keyItra = keys.iterator();
while (keyItra.hasNext()) {
String k = (String) keyItra.next();
String Message = inboxMsg.get(k);
notiTextView.setText(Message);
}
}
});
if(savedInstanceState == null)
{
String Mesage = getIntent().getExtras().getString("Message");
String Time = getIntent().getExtras().getString("Time");
inboxMsg.put(Integer.toString(++Id), "Message is " + Mesage + " Time " + Time + "\n");
}
}
where is the problem kindly redirect me to the correct path, also kindly guide me how to achive this.