2024年4月1日发(作者:)
一、MainActivity中的代码:
package ;
import ar;
import ty;
import anager;
import ialog;
import gIntent;
import ckerDialog;
import Interface;
import ;
import Preferences;
import ;
import nt;
import Inflater;
import Event;
import ;
import ;
import xt;
import ew;
import cker;
import ;
public class MainActivity extends Activity {
TextView setTime1;
TextView setTime2;
TextView setTime3;
Button mButton1;
Button mButton2;
Button mButton3;
Button mButton4;
Button mButton5;
Button mButton6;
String time1String = null;
String time2String = null;
String time3String = null;
String defalutString = "目前无设置";
AlertDialog builder = null;
Calendar c=tance();
@Override
public void onCreate(Bundle savedInstanceState)
{
te(savedInstanceState);
setContentView();
//取得活动的Preferences对象
SharedPreferences settings =
getPreferences(_PRIVATE);
time1String = ing("TIME1", defalutString);
time2String = ing("TIME2", defalutString);
time3String = ing("TIME3", defalutString);
InitButton1();
InitButton2();
InitButton3();
InitButton4();
InitButton5();
InitButton6();
t(time1String);
t(time2String);
t(time3String);
}
public void InitButton1()
{
setTime1=(TextView) findViewById(e1);
mButton1=(Button)findViewById(n1);
lickListener(new kListener()
{
public void onClick(View v)
{
eInMillis(tTimeMillis());
int mHour=(_OF_DAY);
int mMinute=();
new TimePickerDialog(,
new SetListener()
{
public void onTimeSet(TimePicker view,int hourOfDay,
int minute)
{
eInMillis(tTimeMillis());
(_OF_DAY,hourOfDay);
(,minute);
(,0);
(ECOND,0);
Intent intent = new Intent(,
);
PendingIntent sender=adcast(
,0, intent, 0);
AlarmManager am;
am = (AlarmManager)getSystemService(ALARM_SERVICE);
(_WAKEUP,
eInMillis(),
sender
);
String tmpS=format(hourOfDay)+":"+format(minute);
t(tmpS);
//SharedPreferences保存数据,并提交
SharedPreferences time1Share = getPreferences(0);
editor = ();
ing("TIME1", tmpS);
();
xt(,"设置大明闹钟时间为
"+tmpS,
_SHORT)
.show();
}
},mHour,mMinute,true).show();
}
});
}
public void InitButton2()
{
mButton2=(Button) findViewById(n2);
lickListener(new kListener()
{
public void onClick(View v)
{
Intent intent = new Intent(,
);
PendingIntent sender=adcast(
,0, intent, 0);
AlarmManager am;
am =(AlarmManager)getSystemService(ALARM_SERVICE);
(sender);
xt(,"大明闹钟时间删除",
_SHORT).show();
t("目前无设置");
SharedPreferences time1Share = getPreferences(0);
editor = ();
ing("TIME1", "目前无设置");
();
}
});
}
public void InitButton3()
{
setTime3=(TextView) findViewById(e5);
mButton3=(Button)findViewById(n5);
lickListener(new kListener()
{
public void onClick(View v)
{
eInMillis(tTimeMillis());
int mHour=(_OF_DAY);
int mMinute=();
new TimePickerDialog(,
new SetListener()
{
public void onTimeSet(TimePicker view,int hourOfDay,
int minute)
{
eInMillis(tTimeMillis());
(_OF_DAY,hourOfDay);
(,minute);
(,0);
(ECOND,0);
Intent intent = new Intent(,
);
PendingIntent sender=adcast(
,1, intent, 0);
AlarmManager am;
am = (AlarmManager)getSystemService(ALARM_SERVICE);
(_WAKEUP,
eInMillis(),
sender
);
String tmpS=format(hourOfDay)+":"+format(minute);
t(tmpS);
//SharedPreferences保存数据,并提交
SharedPreferences time2Share = getPreferences(1);
editor = ();
ing("TIME2", tmpS);
();
xt(,"设置大明闹钟时间为
"+tmpS,
_SHORT)
.show();
}
},mHour,mMinute,true).show();
}
});
}
public void InitButton4()
{
mButton4=(Button) findViewById(n6);
lickListener(new kListener()
{
public void onClick(View v)
{
Intent intent = new Intent(,
);
PendingIntent sender=adcast(
,0, intent, 0);
AlarmManager am;
am =(AlarmManager)getSystemService(ALARM_SERVICE);
(sender);
xt(,"大明闹钟时间删除",
_SHORT).show();
t("目前无设置");
//SharedPreferences保存数据,并提交
SharedPreferences time2Share = getPreferences(1);
editor = ();
ing("TIME2", "目前无设置");
();
}
});
}
public void InitButton5()
{
setTime2=(TextView) findViewById(e2);
LayoutInflater factory = (this);
final View setView = e(t,null);
final TimePicker tPicker=(TimePicker)setView
.findViewById(r);
24HourView(true);
final AlertDialog di=new r()
.setIcon()
.setTitle("设置")
.setView(setView)
.setPositiveButton("确定",
new kListener()
{
public void onClick(DialogInterface dialog, int which)
{
EditText
ed=(EditText)ewById();
int times=nt(t().toString())
*1000;
eInMillis(tTimeMillis());
(_OF_DAY,rentHour());
(,rentMinute());
(,0);
(ECOND,0);
Intent intent = new Intent(,
);
PendingIntent sender = adcast(
,1, intent, 0);
AlarmManager am;
am = (AlarmManager)getSystemService(ALARM_SERVICE);
eating(_WAKEUP,
eInMillis(),times,sender);
String tmpS=format(rentHour())+":"+
format(rentMinute());
String subStr = "设置大明闹钟时间为"+tmpS+
"开始,重复间隔为"+times/1000+"秒";
t("设置大明闹钟时间为"+tmpS+
"开始,重复间隔为"+times/1000+"秒
");
//SharedPreferences保存数据,并提交
SharedPreferences time3Share = getPreferences(2);
editor = ();
ing("TIME3", subStr);
();
xt(,"设置大明闹钟为
"+tmpS+
"开始,重复间隔为"+times/1000+"秒",
_SHORT).show();
}
})
.setNegativeButton("取消",
new kListener()
{
public void onClick(DialogInterface dialog, int which)
{
}
}).create();
mButton5=(Button) findViewById(n3);
lickListener(new kListener()
{
public void onClick(View v)
{
eInMillis(tTimeMillis());
rentHour((_OF_DAY));
rentMinute(());
();
}
});
}
public void InitButton6()
{
mButton6=(Button) findViewById(n4);
lickListener(new kListener()
{
public void onClick(View v)
{
Intent intent = new Intent(,
);
PendingIntent sender = adcast(
,1, intent, 0);
AlarmManager am;
am = (AlarmManager)getSystemService(ALARM_SERVICE);
(sender);
xt(,"闹钟时间删除",
_SHORT).show();
t("目前无设置");
//SharedPreferences保存数据,并提交
SharedPreferences time3Share = getPreferences(2);
editor = ();
ing("TIME3", "目前无设置");
();
}
});
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(keyCode == E_BACK){
builder = new r()
.setIcon()
.setTitle("温馨提示:")
.setMessage("您是否要退出大明闹钟程序")
.setPositiveButton("确定",
new kListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
();
}
})
.setNegativeButton("取消",
new kListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
s();
}
}).show();
}
return true;
}
private String format(int x)
{
String s=""+x;
if(()==1) s="0"+s;
return s;
}
}
二、CallAlarm中的代码:
package ;
import t;
import ;
import astReceiver;
import ;
public class CallAlarm extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Intent i = new Intent(context, );
Bundle bundleRet = new Bundle();
ing("STR_CALLER", "");
ras(bundleRet);
gs(_ACTIVITY_NEW_TASK);
ctivity(i);
}
}
三、AlarmAlert中的代码:
package ;
import ty;
import ialog;
import Interface;
import ;
public class AlarmAlert extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
te(savedInstanceState);
new r()
.setIcon()
.setTitle("大明闹钟响了!!")
.setMessage("快完成你制定的计划吧")
.setPositiveButton("关掉它",
new kListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
();
}
})
.show();
}
}
四、布局文件的代码:
xmlns:android="/apk/res/android" android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/other" > android:id="@+id/dClock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="40sp" android:textColor="@drawable/blue" android:layout_x="70px" android:layout_y="32px" > android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_title3" android:textSize="20sp" android:textColor="@drawable/black" android:layout_x="10px" android:layout_y="104px" > android:id="@+id/setTime1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_default" android:textColor="@drawable/red" android:textSize="16sp" android:layout_x="10px" android:layout_y="149px" > android:id="@+id/text5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_title4" android:textSize="20sp" android:textColor="@drawable/black" android:layout_x="10px" android:layout_y="216px" > android:id="@+id/setTime5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_default" android:textColor="@drawable/red" android:textSize="16sp" android:layout_x="10px" android:layout_y="259px" > android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_title2" android:textSize="20sp" android:textColor="@drawable/black" android:layout_x="10px" android:layout_y="326px" > android:id="@+id/setTime2" android:layout_width="170px" android:layout_height="wrap_content" android:text="@string/str_default" android:textColor="@drawable/red" android:textSize="16sp" android:layout_x="10px" android:layout_y="369px" >
五、布局文件中的代码:
android:id="@+id/layout2" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="/apk/res/android" > android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_text1" android:textColor="@drawable/white" android:textSize="16sp" android:layout_x="10px" android:layout_y="32px" > android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_text2" android:textColor="@drawable/white" android:textSize="16sp" android:layout_x="10px" android:layout_y="172px" > android:id="@+id/tPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="100px" android:layout_y="12px" > android:id="@+id/mEdit" android:layout_width="52px" android:layout_height="40px" android:text="15" android:textSize="16sp" android:layout_x="120px" android:layout_y="162px" > android:id="@+id/text3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_text3" android:textColor="@drawable/white" android:textSize="16sp" android:layout_x="180px" android:layout_y="172px" >
六、中的代码:
七:中的代码:
八、中的代码
package="" android:versionCode="1" android:versionName="1.0"> android:label="@string/app_name"> /> android:label="@string/app_name"> android:name="ER" /> android:label="@string/app_name">


发布评论