일단 소스
package com.samsung.Noti_test;
import java.io.File;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
public class Noti_test extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private int count = 0;
private File[] strs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File sdcard = new File("/sdcard/capturedPicture/");
strs = sdcard.listFiles();
this.findViewById(R.id.Button01).setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String filename = strs[count].getAbsolutePath();
Intent intent = new Intent(this, SelectedGallary.class);
intent.putExtra("filename", filename);
Log.e("Gallery1", filename);
intent.putExtra("filename_display", filename);
intent.putExtra("Notification_code", count);
NotificationManager nm = (NotificationManager) this
.getSystemService(this.NOTIFICATION_SERVICE);
Notification notification = new Notification(
android.R.drawable.btn_star, "Test", System
.currentTimeMillis());
PendingIntent pending = PendingIntent
.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "Test",
count+"", pending);
nm.notify(count, notification);
if (count <= strs.length) {
count++;
}
}
}
package com.samsung.Noti_test;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
public class SelectedGallary extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.show_file);
Intent getIntent = getIntent();
String filename = getIntent.getStringExtra("filename");
Log.e("______________________________", filename);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Log.e("______________________________", getIntent.getIntExtra("Notification_code", 11111)+"");;
nm.cancel(getIntent.getIntExtra("Notification_code", 11111));
ImageView i = (ImageView) this.findViewById(R.id.SelectedImage);
try {
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inSampleSize = 7;
Bitmap bm = BitmapFactory.decodeFile(filename, bfo);
i.setImageBitmap(bm);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
간단한 노티 테스트인데요.
특정폴더에 저장된 10개의 이미지파일을 보여줍니다.
버튼을 누를때마다 0,1,2,3,4... 이런식으로 알림을 어레이에 연결해서 보여주는데
0번이든 4번이든 무조건 0번의 정보가 들어가서 액티비티가 실행되네요;;;;
이거 왜 이러는지 아시는 분 답변좀 부탁드립니더 ㅠㅠ