Friday, June 20, 2014
Friday, January 10, 2014
intent on wifi signal strength change
INTENT ON WIFI SIGNAL STRENGTH
CHANGE
declare the manifest as shown below
CHANGEdeclare the manifest as shown below
<manifest ... > ... <application ... > <service android:name=".ExampleService" /> ... </application> </manifest>
here's an example of implementation of IntentService
public class HelloIntentService extends IntentService {
/**
* A constructor is required, and must call the super IntentService(String)
* constructor with a name for the worker thread.
*/
public HelloIntentService() {
super("HelloIntentService");
}
/**
* The IntentService calls this method from the default worker thread with
* the intent that started the service. When this method returns, IntentService
* stops the service, as appropriate.
*/
@Override
protected void onHandleIntent(Intent intent) {
// Normally we would do some work here, like download a file.
// For our sample, we just sleep for 5 seconds.
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
}
}
For example, onStartCommand() must return
the default implementation (which is how the intent gets delivered to onHandleIntent()):
@Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); return super.onStartCommand(intent,flags,startId); }
--------------------------------------------------------------------------------------------------
same code but work by implementation of services
public class HelloService extends Service { private Looper mServiceLooper; private ServiceHandler mServiceHandler; // Handler that receives messages from the thread private final class ServiceHandler extends Handler { public ServiceHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { // Normally we would do some work here, like download a file. // For our sample, we just sleep for 5 seconds. long endTime = System.currentTimeMillis() + 5*1000; while (System.currentTimeMillis() < endTime) { synchronized (this) { try { wait(endTime - System.currentTimeMillis()); } catch (Exception e) { } } } // Stop the service using the startId, so that we don't stop // the service in the middle of handling another job stopSelf(msg.arg1); } } @Override public void onCreate() { // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it // background priority so CPU-intensive work will not disrupt our UI. HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); // Get the HandlerThread's Looper and use it for our Handler mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); // For each start request, send a message to start a job and deliver the // start ID so we know which request we're stopping when we finish the job Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; mServiceHandler.sendMessage(msg); // If we get killed, after returning from here, restart return START_STICKY; } @Override public IBinder onBind(Intent intent) { // We don't provide binding, so return null return null; } @Override public void onDestroy() { Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show(); } }
-------------------------------------------------------------------------------------------------
notification for the status bar
Notification notification = new Notification(R.drawable.icon, getText(R.string.ticker_text), System.currentTimeMillis()); Intent notificationIntent = new Intent(this, ExampleActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(this, getText(R.string.notification_title), getText(R.string.notification_message), pendingIntent); startForeground(ONGOING_NOTIFICATION_ID, notification);
-------------------------------------------------------------------------------------------------
implementing the lifecycle callbacks
public class ExampleService extends Service { int mStartMode; // indicates how to behave if the service is killed IBinder mBinder; // interface for clients that bind boolean mAllowRebind; // indicates whether onRebind should be used @Override public voidonCreate() { // The service is being created } @Override public intonStartCommand(Intent intent, int flags, int startId) { // The service is starting, due to a call tostartService()return mStartMode; } @Override public IBinderonBind(Intent intent) { // A client is binding to the service withbindService()return mBinder; } @Override public booleanonUnbind(Intent intent) { // All clients have unbound withunbindService()return mAllowRebind; } @Override public voidonRebind(Intent intent) { // A client is binding to the service withbindService(), // after onUnbind() has already been called } @Override public voidonDestroy() { // The service is no longer used and is being destroyed } }
---------------------------------------------------------------------------------------------
click here for a source page
Tuesday, January 7, 2014
registration form in html
REGISTRATION FORM IN HTML
well for beginners in HTML ,should make registration form .
It will tell you that how graphics are made.
there is a code of registration form in HTML-
well for beginners in HTML ,should make registration form .
It will tell you that how graphics are made.
there is a code of registration form in HTML-
<!doctype html>
<style type="text/css">
body {font-family:Arial, Sans-Serif;}
#container {width:300px; margin:0 auto;}
/* Nicely lines up the labels. */
form label {display:inline-block; width:140px;}
/* You could add a class to all the input boxes instead, if you like. That would be safer, and more backwards-compatible */
form input[type="text"],
form input[type="password"],
form input[type="email"] {width:160px;}
form .line {clear:both;}
form .line.submit {text-align:right;}
</style>
<div id="container">
<form>
<h1>Create Logon</h1>
<div class="line"><label for="username">Username *: </label><input type="text" id="username" /></div>
<div class="line"><label for="pwd">Password *: </label><input type="password" id="pwd" /></div>
<!-- You may want to consider adding a "confirm" password box also -->
<div class="line"><label for="surname">Surname *: </label><input type="text" id="surname" /></div>
<div class="line"><label for="other_names">Other Names *: </label><input type="text" id="names" /></div>
<div class="line"><label for="dob">Date of Birth *: </label><input type="text" id="dob" /></div>
<div class="line"><label for="email">Email *: </label><input type="email" id="email" /></div>
<!-- Valid input types: http://www.w3schools.com/html5/html5_form_input_types.asp -->
<div class="line"><label for="tel">Telephone: </label><input type="text" id="tel" /></div>
<div class="line"><label for="add">Address *: </label><input type="text" id="add" /></div>
<div class="line"><label for="ptc">Post Code *: </label><input type="text" id="ptc" /></div>
<div class="line submit"><input type="submit" value="Submit" /></div>
<p>Note: Please make sure your details are correct before submitting form and that all fields marked with * are completed!.</p>
</form>
</div>
</!doctype>
<style type="text/css">
body {font-family:Arial, Sans-Serif;}
#container {width:300px; margin:0 auto;}
/* Nicely lines up the labels. */
form label {display:inline-block; width:140px;}
/* You could add a class to all the input boxes instead, if you like. That would be safer, and more backwards-compatible */
form input[type="text"],
form input[type="password"],
form input[type="email"] {width:160px;}
form .line {clear:both;}
form .line.submit {text-align:right;}
</style>
<div id="container">
<form>
<h1>Create Logon</h1>
<div class="line"><label for="username">Username *: </label><input type="text" id="username" /></div>
<div class="line"><label for="pwd">Password *: </label><input type="password" id="pwd" /></div>
<!-- You may want to consider adding a "confirm" password box also -->
<div class="line"><label for="surname">Surname *: </label><input type="text" id="surname" /></div>
<div class="line"><label for="other_names">Other Names *: </label><input type="text" id="names" /></div>
<div class="line"><label for="dob">Date of Birth *: </label><input type="text" id="dob" /></div>
<div class="line"><label for="email">Email *: </label><input type="email" id="email" /></div>
<!-- Valid input types: http://www.w3schools.com/html5/html5_form_input_types.asp -->
<div class="line"><label for="tel">Telephone: </label><input type="text" id="tel" /></div>
<div class="line"><label for="add">Address *: </label><input type="text" id="add" /></div>
<div class="line"><label for="ptc">Post Code *: </label><input type="text" id="ptc" /></div>
<div class="line submit"><input type="submit" value="Submit" /></div>
<p>Note: Please make sure your details are correct before submitting form and that all fields marked with * are completed!.</p>
</form>
</div>
</!doctype>
Subscribe to:
Posts (Atom)


