4

우리는 내가 백그라운드 프로세스를 시작하기위한 알람 매니저를 사용하고,이에합격 값은

Intent ij = new Intent(context,DemoActivity.class); 
    PendingIntent operation = PendingIntent.getActivity(getBaseContext(),0,ij,Intent.FLAG_ACTIVITY_NEW_TASK); 
    AlarmManager alarmManager = (AlarmManager) getBaseContext().getSystemService(ALARM_SERVICE); 
    GregorianCalendar calendar = new GregorianCalendar(y, m, d,hr, mi); 
    long alarm_time = calendar.getTimeInMillis(); 
    alarmManager.set(AlarmManager.RTC_WAKEUP,alarm_time,operation); 

.. 백그라운드 프로세스에 대한 보류중인 의도에 인수를 전달할 수 있습니다. 이 방법을 사용하면 변수 나 인수를 전달할 수 있습니까?

public class DemoActivity extends FragmentActivity { 


protected void onCreate(Bundle savedInstanceState) {   
    super.onCreate(savedInstanceState); 
/** Creating an Alert Dialog Window */ 
    AlertDemo alert = new AlertDemo(); 

    /** Opening the Alert Dialog Window */ 
    alert.show(getSupportFragmentManager(), "AlertDemo");  
} 
} 

그리고 난 그냥 경고 상자를 사용하여 경고 데모 클래스의

.. 지금 어디에 넣어 Exatra 방법을 배치, 나를 도와? ..

+2

난 당신이 캘리포니아 생각 n Intent ** ij **로 값을 전달하십시오. –

+0

@Gowri shankar, 답변 확인을 편집했습니다 –

답변

10

예는 다음과 같은 의도를 보류 변수를 전달할 수 있습니다 :

  Intent in = new Intent(context, DemoActivity.class); 
      in.putExtra("notification_id", REGISTER_NOTIF_ID); 
      in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      in.putExtra("2", Variable); 
      in.putExtra("1", Variable); 
      in.putExtra("IMData", Variable); 
      PendingIntent contentIntent = PendingIntent.getActivity(context, 0, in, 0); 

과 당신의 DemoActivity 클래스의 사용자에서 onCreate에서 다음을 수행하십시오

Bundle extras = getIntent().getExtras(); 

    userGetId = extras.getString("2"); 
    userNameRecv = extras.getString("1"); 
    userFriendId = extras.getString("IMData") 
+2

이 대답은 질문에서 잘못 사용 된 Intent.FLAG_ACTIVITY_NEW_TASK을 (를) 추가하는 올바른 방법을 보여줍니다. – JNissi

+0

예, 정확히 하나, 나는 그걸 관찰했습니다 –

+2

다음 활동 (백그라운드 프로세스)에서 변수를 받거나 가져올 수 있습니까? ... – gowri