게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
안드로이드 intent getExtra 관련해서 궁금한게있습니다!
게시물ID : programmer_7541짧은주소 복사하기
작성자 : LemoLemo
추천 : 0
조회수 : 2845회
댓글수 : 3개
등록시간 : 2015/01/08 16:50:23
안녕하세요 현제 안드로이드 공부중인데요
 
제가만드는게 인텐트에서 인텐트로 Extra로 데이터넘기는건데요
 
처음에 1번 엑티비티에 a라는 데이터를 넘겨주면 a를 잘받아오는데요
 
그다음에 종료하지않고 다시 b라는 데이터를 넘겨주면
 
인텐트에 데이터가 그대로 a가 남아있더라구요
 
계속 넘겨주는거에따라 데이터를 바꿀수없을까요??
 
답변부탁드립니다!
 
----인텐트 호출하는 소스입니다
 
 private static void generateNotification(Context context, String message,String param,String param1) {
  
  Log.e("process","Noti 3"+param);
  
  int icon = R.drawable.ic_launcher;
  long when = System.currentTimeMillis();
  
  NotificationManager notificationManager = (NotificationManager) context
  .getSystemService(Context.NOTIFICATION_SERVICE);
  
  
  Notification notification = new Notification(icon, message, when);
  
  notification.vibrate = new long[] { 150, 100, 150, 100 };
  notification.defaults |= Notification.DEFAULT_SOUND;
  
  String title = context.getString(R.string.app_name);
  
  Intent notificationIntent = new Intent(context, RedirectActivity.class);
  
  
  notificationIntent.putExtra("param", param);
  notificationIntent.putExtra("param1", param1);
  
  notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
          | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  PendingIntent intent = PendingIntent.getActivity(context, 0,
  notificationIntent, 0);
  
  notification.setLatestEventInfo(context, title, message, intent);
  notification.flags |= Notification.FLAG_AUTO_CANCEL;
  notificationManager.notify(0, notification);
 
 }
 
--------받는 엑티비티 소스입니다
 
package com.xenixstudio.kepco;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
public class RedirectActivity extends Activity {
 
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.redirect_layout);
  
  
 }
 
 @Override
 protected void onResume() {
  // TODO Auto-generated method stub
  super.onResume();
  Intent intent = getIntent();
  
  String param = intent.getExtras().getString("param");
  Log.e("Redi Param",param);
  String param1 = intent.getExtras().getString("param1");
  
  if(param.equals("home")){
  Intent redirect = new Intent(RedirectActivity.this,HomeActivity.class);
  startActivity(redirect);
  
  }else{
   
  Intent redirect = new Intent(RedirectActivity.this,CounselActivity.class);
  redirect.putExtra("param",param);
  redirect.putExtra("param1",param1);
  startActivity(redirect);
  }
  
 }
 
}
꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호