package com.zhuyan;
import java.util.Calendar;
import com.zhuyan.broadcast.AlarmReceiver;
import com.zhuyan.dialog.LongClickDialog;
import android.util.Log;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
public class TimingDialActivity extends Activity {
/** Called when the activity is first created. */
private static final String TAG = "TimingDialActivity";
Button mButtonStart;
Button mButtonStop;
EditText interval;
EditText telPhoneEditText;
LongClickDialog dialog;
TextView mTextView;
Calendar calendar;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
calendar = Calendar.getInstance();
mTextView = (TextView) findViewById(R.id.phone_view);
mButtonStart = (Button) findViewById(R.id.set_time);
mButtonStop = (Button) findViewById(R.id.cancel_time);
interval = (EditText) findViewById(R.id.interval);
telPhoneEditText = (EditText) findViewById(R.id.tel_number);
dialog = new LongClickDialog(this, telPhoneEditText);
telPhoneEditText.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Log.i(TAG, "");
dialog.show();
return true;
}
});
mButtonStart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
calendar.setTimeInMillis(System.currentTimeMillis());
int mHour = calendar.get(Calendar.HOUR_OF_DAY);
int mMinute = calendar.get(Calendar.MINUTE);
new TimePickerDialog(TimingDialActivity.this,
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view,
int hourOfDay, int minute) {
calendar.setTimeInMillis(System
.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Intent intent = new Intent(
TimingDialActivity.this,
AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent
.getBroadcast(TimingDialActivity.this,
0, intent, 0);
AlarmManager am;
am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(),
pendingIntent);
String tmpS = telPhoneEditText.getText()
.toString()
+ "->"
+ format(hourOfDay)
+ ":" + format(minute);
int tempInterval = 0;
if (!interval.getText().toString().equals("")) {
tempInterval = Integer.valueOf(interval
.getText().toString());
}
SharedPreferences preference = getSharedPreferences(
"zhuyan", Context.MODE_PRIVATE);
Editor edit = preference.edit();
edit.putString("tel_phone", telPhoneEditText
.getText().toString());
edit.putString("info", mTextView.getText()
.toString());
if (tempInterval != 0) {
edit.putLong("time",
calendar.getTimeInMillis()
+ tempInterval * 60 * 1000);
tmpS += "//interval time is "
+ tempInterval + "minters";
}else{
edit.putLong("time",0);
}
edit.commit();
mTextView.setText(tmpS);
}
}, mHour, mMinute, true).show();
}
});
mButtonStop.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(TimingDialActivity.this,
AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
TimingDialActivity.this, 0, intent, 0);
AlarmManager am;
am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.cancel(pendingIntent);
mTextView.setText("Cancelled");
}
});
}
/* ��ʽ���ַ�(7:3->07:03) */
private String format(int x) {
String s = "" + x;
if (s.length() == 1)
s = "0" + s;
return s;
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
SharedPreferences preference = getSharedPreferences("zhuyan",
Context.MODE_PRIVATE);
telPhoneEditText.setText(preference.getString("tel_phone", "10086"));
mTextView.setText(preference.getString("info", "demo"));
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
SharedPreferences preference = getSharedPreferences("zhuyan",
Context.MODE_PRIVATE);
Editor edit = preference.edit();
edit.putString("tel_phone", telPhoneEditText.getText().toString());
edit.putString("info", mTextView.getText().toString());
edit.commit();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 系统工具 简单代码实现的计算器源码.rar
共43个文件
class:18个
java:7个
png:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 139 浏览量
2023-03-29
19:56:31
上传
评论
收藏 82KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 系统工具 简单代码实现的计算器源码.rar (43个子文件)
简单代码实现的Android 计算器源码
project.properties 376B
.classpath 356B
assets
src
com
zhuyan
adapter
DialogListViewAdapter.java 3KB
dialog
LongClickDialog.java 1KB
TimingDialActivity.java 5KB
service
TimingDialService.java 273B
model
Person.java 537B
broadcast
AlarmReceiver.java 2KB
res
drawable-mdpi
ic_launcher.png 3KB
drawable-ldpi
ic_launcher.png 2KB
values
strings.xml 263B
layout
main.xml 1KB
dialog_listview_view.xml 272B
dialog_listview_item.xml 877B
drawable-hdpi
icon.png 3KB
bin
classes
com
zhuyan
TimingDialActivity$2.class 2KB
adapter
DialogListViewAdapter$ViewHolder.class 485B
DialogListViewAdapter.class 4KB
TimingDialActivity$3.class 2KB
dialog
LongClickDialog$1.class 2KB
LongClickDialog.class 2KB
R$string.class 470B
R$layout.class 458B
TimingDialActivity$2$1.class 4KB
R$id.class 575B
service
TimingDialService.class 477B
R$attr.class 316B
model
Person.class 835B
R$drawable.class 411B
TimingDialActivity.class 4KB
broadcast
AlarmReceiver.class 3KB
R.class 475B
TimingDialActivity$1.class 1KB
resources.ap_ 12KB
res
drawable-mdpi
ic_launcher.png 2KB
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
icon.png 3KB
classes.dex 14KB
TimingDial.apk 20KB
proguard.cfg 1KB
.project 813B
AndroidManifest.xml 1KB
gen
com
zhuyan
R.java 1KB
共 43 条
- 1
资源评论
荣华富贵8
- 粉丝: 216
- 资源: 7653
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功