Back to project page lunatick.
The source code is released under:
Copyright (c) 2014, a. bellenir All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1....
If you think the Android project lunatick listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.bellenir.lunatick; /* w ww .ja v a 2 s . com*/ import android.app.Activity; import android.os.Bundle; import android.widget.ImageView; import android.graphics.*; import java.util.Calendar; import android.widget.*; import android.content.pm.*; import android.content.*; import android.view.View; import android.view.View.*; import android.os.*; public class Info extends Activity { ImageView imgLT; Handler handler = new Handler(); Runnable refresh; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.widget); imgLT = (ImageView)findViewById(R.id.Lunatick); openClockOnClick(); refresh = new Runnable(){ public void run(){ drawImage(); long sleep = 1000-Calendar.getInstance().get(Calendar.MILLISECOND); handler.postDelayed(refresh, sleep); } }; handler.post(refresh); } private void drawImage(){ try{ Bitmap bmp = LunaTick.getLunaTickBmp(true); imgLT.setImageBitmap(bmp); }catch(Exception e){ toast(e.getMessage()); } } private void openClockOnClick(){ imgLT.setOnClickListener(new OnClickListener(){ public void onClick(View v){ PackageManager packageManager = v.getContext().getPackageManager(); if (packageManager != null) { Intent AlarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory( Intent.CATEGORY_LAUNCHER).setComponent( new ComponentName("com.android.deskclock", "com.android.deskclock.DeskClock")); ResolveInfo resolved = packageManager.resolveActivity(AlarmClockIntent, PackageManager.MATCH_DEFAULT_ONLY); if (resolved != null) { startActivity(AlarmClockIntent); //finish(); //return; } else { Toast.makeText(v.getContext(), "failed to launch", Toast.LENGTH_LONG); // required activity can not be located! } } }}); } private void toast(String s){ Toast.makeText(this, s, Toast.LENGTH_LONG).show(); } }