분류 전체보기
- [iOS] NSObject "load" method 2010.11.30
- [Android] Activity 에서 Dialog 띄우기. 2010.11.30
- [Android] string.xml 에서 ' (apostrophe) 사용하기. 2010.11.30
- [Android] TextView로 시계 출력하기. 2010.11.30
- iOS SandBox Path. 2010.11.29
- iOS SDK 에서 Email 보내기 2010.11.27
- Interface Builder 에서 Status Bar 숨기기. 2010.11.26
- [Android] DeskClock 분석#3 - 알람 등록( AlramManager ) 2010.11.26
- XCode 3.2.5, iOS4.2 에서 Base SDK Simulator로 설정하기. 2010.11.26
- [iOS] 외부라이브러리에서 unrecognized selector 에러가 날때... 2010.11.26
[iOS] NSObject "load" method
[Android] Activity 에서 Dialog 띄우기.
@Override
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("AlertDialog")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
return alert;
}
[Android] string.xml 에서 ' (apostrophe) 사용하기.
[Android] TextView로 시계 출력하기.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mCurTimeTextView = (TextView) findViewById(R.id.CurrentTimeTextView);
MainTimerTask timerTask = new MainTimerTask();
mTimer = new Timer();
mTimer.schedule(timerTask, 500, 1000);
}
private Handler mHandler = new Handler();
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
......
}
};
class MainTimerTask extends TimerTask {
public void run() {
mHandler.post(mUpdateTimeTask);
}
}
Date rightNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(
"hh:mm:ss dd.MM.yyyy");
String dateString = formatter.format(rightNow);
mCurTimeTextView.setText(dateString);
@Override
protected void onDestroy() {
mTimer.cancel();
super.onDestroy();
}
@Override
protected void onPause() {
mTimer.cancel();
super.onPause();
}
@Override
protected void onResume() {
MainTimerTask timerTask = new MainTimerTask();
mTimer.schedule(timerTask, 500, 3000);
super.onResume();
}
iOS SandBox Path.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
iOS SDK 에서 Email 보내기
Interface Builder 에서 Status Bar 숨기기.
[Android] DeskClock 분석#3 - 알람 등록( AlramManager )
public static long addAlarm(Context context, Alarm alarm) {
ContentValues values = createContentValues(alarm);
Uri uri = context.getContentResolver().insert(
Alarm.Columns.CONTENT_URI, values);
alarm.id = (int) ContentUris.parseId(uri);
long timeInMillis = calculateAlarm(alarm);
if (alarm.enabled) {
clearSnoozeIfNeeded(context, timeInMillis);
}
setNextAlert(context);
return timeInMillis;
private static void enableAlert(Context context, final Alarm alarm,
final long atTimeInMillis) {
AlarmManager am = (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
if (Log.LOGV) {
Log.v("** setAlert id " + alarm.id + " atTime " + atTimeInMillis);
}
Intent intent = new Intent(ALARM_ALERT_ACTION);
Parcel out = Parcel.obtain();
alarm.writeToParcel(out, 0);
out.setDataPosition(0);
intent.putExtra(ALARM_RAW_DATA, out.marshall());
PendingIntent sender = PendingIntent.getBroadcast(
context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender);
setStatusBarIcon(context, true);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(atTimeInMillis);
String timeString = formatDayAndTime(context, c);
saveNextAlarm(context, timeString);
}