私は1つの活動をしています:
...
super.onCreate(savedInstanceState);
setContentView(R.layout.configure);
edit1=(EditText) findViewById(R.id.edit1);
edit2=(EditText) findViewById(R.id.edit2);
edit11=edit1.getText().toString();
edit22=edit2.getText().toString();
btn=(View) findViewById(R.id.btn);
btn.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()){
case R.id.btn:
Intent i=new Intent(this,selection.class);
i.putExtra("code_value",edit11);
i.putExtra("time_value",edit22);
startActivity(i);
break;
}
および選択アクティビティでは:
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.selection);
String code_value=getIntent().getExtras().getString("code_value");
String time_value=getIntent().getExtras().getString("time_value");
long thetime=Long.parseLong(time_value);
..
// Start service using AlarmManager
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 10);
Intent intent = new Intent(selection.this, selection.class);
PendingIntent pintent = PendingIntent.getService(selection.this, 0, intent,
0);
AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
thetime, pintent);
長い「thetime」は、alarm.setRepeating で使用したいところです。しかし、それは私にnullpointerexceptionを与えます..