package android.AlarmTest_F;
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Timer extends Activity {
public static final String KEY_MY_PREFERENCE = "my_preference";
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent;
PendingIntent sender;
SharedPreferences pref1 = getSharedPreferences("PrefTime", 0);
int timer = pref1.getInt(KEY_MY_PREFERENCE, 0);
EditText hour = (EditText)findViewById(R.id.t_hour);
EditText min = (EditText)findViewById(R.id.t_min);
EditText sec = (EditText)findViewById(R.id.t_sec);
int tHour;
int tMin;
int tSec;
int tTime;
if(timer>=3600)
{
tHour = timer / 3600;
tTime = timer % 3600;
if(tTime>=60)
{
tMin = tTime / 60;
tSec = tTime % 60;
}
else
{
tMin = 00;
tSec = tTime;
}
}
else
{
tHour = 00;
if(tTime>=60)
{
tMin = tTime / 60;
tSec = tTime % 60;
}
else
{
tMin = 00;
tSec = tTime;
}
}
hour.setText(""+tHour);
min.setText(""+tMin);
sec.setText(""+tSec);
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timer);
Button btnStart = (Button)findViewById(R.id.start);
btnStart.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
// 예약에 의해 호출될 BR 지정
intent = new Intent(Timer.this, AlarmReceiver.class);
sender = PendingIntent.getBroadcast(Timer.this, 0, intent, 0);
// 알람 시간
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, timer);
// 알람 등록
am.set(AlarmManager.RTC, calendar.getTimeInMillis(), sender);
}
});
}
}
알람이 돌아가고 있는걸 보여주기 위해서 사용자에게 알람 시간을 받는 엑티비티에서 시간을 받아와서 타이머 처럼 EditText에 시 : 분 :초
이렇게 표시해서 하려구 하는데요.
사용자에 받은 시간은 초 단위로 변경했구, 이 엑티비티에서 다시 시, 분, 초로 onCreate 되기전에 변경하려구 위에다 코딩했습니다.
그런데 첫번째 음영처리 한곳에서 Syntax error on token ";", { expected after this token
두번째, 세번째
Multiple markers at this line
- Syntax error on token "(", ;
expected
- overrides
android.app.Activity.onCreate
- Syntax error on token ")", ;
expected
네번째
Syntax error, insert "}" to complete ClassBody
이런 오류가 나는데요..... 왜 이런 오류가 나는건가요? 이유를 모르겟습니다.