336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.example.alarm; 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.os.Bundle; import android.view.View; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; public class MainActivity extends Activity { DatePicker mDate; TextView mTxtDate; TimePicker mTime; TextView mTxtTime; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDate = (DatePicker)findViewById(R.id.datepicker); mDate.init(mDate.getYear(), mDate.getMonth(), mDate.getDayOfMonth(), new DatePicker.OnDateChangedListener() { public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mTxtDate.setText(String.format("%d/%d/%d", year, monthOfYear + 1, dayOfMonth)); } }); // 시간 선택기 mTime = (TimePicker) findViewById(R.id.timepicker); mTxtTime = (TextView) findViewById(R.id.txttime); mTime.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { mTxtTime.setText(String.format("%d:%d", hourOfDay, minute)); } }); // 24시간제 토글 findViewById(R.id.btntoggle24).setOnClickListener( new View.OnClickListener() { public void onClick(View v) { mTime.setIs24HourView(!mTime.is24HourView()); } }); } public void mOnClick(View v) { String result = String.format("%d/%d/%d %d:%d", mDate.getYear(), mDate.getMonth() + 1, mDate.getDayOfMonth(), mTime.getCurrentHour(), mTime.getCurrentMinute()); Toast.makeText(MainActivity.this, result + "로 알람이 설정 되었습니다.", 0).show(); // 알람 매니저에 등록할 인텐트를 만듬 Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0); // 알람을 받을 시간을 5초 뒤로 설정 Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 50); // 알람 매니저에 알람을 등록 AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); } } package com.example.alarm; import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.widget.Toast; public class AlarmReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Toast.makeText(context, "It's time to start", Toast.LENGTH_LONG).show(); Intent i = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse("mms://114.108.140.39/magicfm_live"); i.setDataAndType(uri, "video/mp4"); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_ONE_SHOT); try { pi.send(); } catch (CanceledException e) { e.printStackTrace(); } } }
'Programming > Android' 카테고리의 다른 글
Andoid 매트로돔 (0) | 2013.08.19 |
---|---|
Android 시계 (0) | 2013.08.19 |
Android 라디오 mms 주소로 듣기 (1) | 2013.08.16 |
Android Intro 로딩 Activity (0) | 2013.08.12 |
Android 전화번호부 목록 ListView에 띄우기 (0) | 2013.08.09 |