Android开发片段–代码中设定系统定时

设置 

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
		try {
			js = new JSONArray(timeArray);
			String str = "";
			for(int i=0;i<js.length();i++) {
				str = js.get(i).toString().replaceAll("T", " ");
				try {
					date = format1.parse(str);
		    		Log.i(TAG, format1.format(date)+"");
		    		calendar.setTime(date);
		    		Log.i(TAG, calendar.getTimeInMillis()+" calendar");
				} catch (ParseException e) {
					e.printStackTrace();
				}
				PendingIntent pendingIntent = PendingIntent.getBroadcast(Alarm.this, i, intent, 0);
				alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

 接收

public class AlarmReceiver extends BroadcastReceiver {
	NotificationManager mn ;
	Notification notification;
	/* (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context arg0, Intent data) {
		Log.d(Alarm.TAG, "the time is up,start the alarm...");
		setStatusBar(arg0,R.drawable.smile,"作業時間","作業時間","ただ今新しい作業時間になりました。");
	}
	public void setStatusBar(Context context,int iconImage, String statusBarText,String title,String content) {
		mn =( NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
		notification = new Notification(iconImage,statusBarText, System.currentTimeMillis());
		notification.defaults |= Notification.DEFAULT_LIGHTS;
		notification.sound = Uri.parse("android.resource://" + context.getPackageName()
				+ "/" + R.raw.message);
        PendingIntent contentIntent=PendingIntent.getActivity(context,
                0, null, 0);
        notification.setLatestEventInfo(context,title, content, contentIntent);
        mn.notify(1, notification);
        
	 }
}
 

配置

 <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <receiver
            android:name="com.zzh.alermactivity.AlarmReceiver"
            android:process=":remote" />

        <activity
            android:label="@string/app_name"
            android:name="com.zzh.alermactivity.Alarm" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
 
【A股温度计】www.agwdj.com 镜像版程序V1.0说明 •通过数据可视化技术,将复杂的A股市场数据转化为直观的图形界面,帮助投资者快速把握市场脉搏。 【核心功能】 •全景视角:突破信息碎片化局限,快速定位涨跌分布,一眼锁定今日热点板块 •板块排序:基于申万行业分类标准,对31个一级行业和131个二级行业实时动态排序 •硬件适配:智能适配不同分辨率屏幕,4K以上屏幕显示信息更多(视觉更佳) •智能缩放:A股全图让大A市场5000+个股同屏显示(支持鼠标滚轮及触摸设备5级缩放) 【三秒原则】 •三秒看懂:通过精心设计的视觉图形,让用户在三秒内看清市场整体状况 •三秒定位:智能算法让大成交额个股和热点板块自动靠前,快速定位机会 •三秒操作:极简的界面,让用户减少操作 【使用场景】 •盘前准备:快速了解隔夜市场变化,制定当日策略 •盘中监控:实时跟踪市场动向,及时把握当日机会 •盘后复盘:全面分析当日市场表现,总结经验教训 【适合人群】 •个人用户:快速了解市场整体趋势变化,辅助决策 •专业人员:获取每天市场的数据云图支持研究工作 •金融机构:作为投研系统的可视化补充组件 •财经媒体:制作专业市场分析图表和报道 【市场切换】 •默认加载"A股全图",可切换单独显示的类型如下: •上证A股/深证A股/北证A股/创业板/科创板/ST板块/可转债/ETF 【程序优势】 •运行环境:纯PHP运行(无需安装任何数据库) •数据更新:实时同步→A股温度计→www.agwdj.com •显示优化:自动适配8K/4K/2K/1080P等不同分辨率的屏幕 •设备兼容:对市面上主流的设备及浏览器做了适配(检测到手机/平板/电视等默认Chrome/Firefox/Edge内核过低的情况会自动提示) 【其他说明】 •A股温度计程序演示网址:https://www.agwdj.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值