How do I shutdown, restart, or log off Windows via a bat file?

The most common ways to use the shutdown command are: shutdown -s — Shuts down. shutdown -r — Restarts. shutdown -l — Logs off. shutdown -h — Hibernates. Note: There is a common pitfall wherein users think -h means “help” (which it does for every other command-line program… except shutdown.exe, where it means “hibernate”). They … Read more

Android AlarmManager after reboot

I’m not sure if I understand the boot receiver and how to then restart all the alarms. Just call your code to call setRepeating() (or whatever) on AlarmManager. For example, in this sample project, PollReceiver is set to receive BOOT_COMPLETED. In onReceive(), it reschedules the alarms: package com.commonsware.android.schedsvc; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import … Read more

android:configChanges=”orientation” does not work with fragments

Based on my experience with Honeycomb 3.0 and compatibility library (r1). configChange=”orientation” does work with fragments with respect to preventing the activity (to which it is applied) being re-created on an orientation change. If you want the fragment not to be re-created on activity re-creation then call setRetainInstance in onCreate. Unless I’m missing something I … Read more

How can I restart a Java application?

Of course it is possible to restart a Java application. The following method shows a way to restart a Java application: public void restartApplication() { final String javaBin = System.getProperty(“java.home”) + File.separator + “bin” + File.separator + “java”; final File currentJar = new File(MyClassInTheJar.class.getProtectionDomain().getCodeSource().getLocation().toURI()); /* is it a jar file? */ if(!currentJar.getName().endsWith(“.jar”)) return; /* Build … Read more