diciembre 25, 2014

Recrear una actividad en android

Recreating an Activity

There are a few scenarios in which your activity is destroyed due to normal app behavior, such as when the user presses the Back button or your activity signals its own destruction by calling finish(). The system may also destroy your activity if it's currently stopped and hasn't been used in a long time or the foreground activity requires more resources so the system must shut down background processes to recover memory.
When your activity is destroyed because the user presses Back or the activity finishes itself, the system's concept of that Activity instance is gone forever because the behavior indicates the activity is no longer needed. However, if the system destroys the activity due to system constraints (rather than normal app behavior), then although the actual Activity instance is gone, the system remembers that it existed such that if the user navigates back to it, the system creates a new instance of the activity using a set of saved data that describes the state of the activity when it was destroyed. The saved data that the system uses to restore the previous state is called the "instance state" and is a collection of key-value pairs stored in a Bundle object.
Caution: Your activity will be destroyed and recreated each time the user rotates the screen. When the screen changes orientation, the system destroys and recreates the foreground activity because the screen configuration has changed and your activity might need to load alternative resources (such as the layout).
By default, the system uses the Bundle instance state to save information about each View object in your activity layout (such as the text value entered into an EditText object). So, if your activity instance is destroyed and recreated, the state of the layout is restored to its previous state with no code required by you. However, your activity might have more state information that you'd like to restore, such as member variables that track the user's progress in the activity.
Note: In order for the Android system to restore the state of the views in your activity, each view must have a unique ID, supplied by the android:id attribute.
To save additional data about the activity state, you must override the onSaveInstanceState() callback method. The system calls this method when the user is leaving your activity and passes it the Bundle object that will be saved in the event that your activity is destroyed unexpectedly. If the system must recreate the activity instance later, it passes the same Bundle object to both the onRestoreInstanceState() and onCreate() methods.

Figure 2. As the system begins to stop your activity, it calls onSaveInstanceState() (1) so you can specify additional state data you'd like to save in case the Activity instance must be recreated. If the activity is destroyed and the same instance must be recreated, the system passes the state data defined at (1) to both the onCreate() method (2) and the onRestoreInstanceState() method (3).

Save Your Activity State


As your activity begins to stop, the system calls onSaveInstanceState() so your activity can save state information with a collection of key-value pairs. The default implementation of this method saves information about the state of the activity's view hierarchy, such as the text in an EditText widget or the scroll position of a ListView.
To save additional state information for your activity, you must implement onSaveInstanceState() and add key-value pairs to the Bundle object. For example:


static final String STATE_SCORE = "playerScore";
static final String STATE_LEVEL = "playerLevel";
...
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save the user's current game state
    savedInstanceState.putInt(STATE_SCORE, mCurrentScore);
    savedInstanceState.putInt(STATE_LEVEL, mCurrentLevel);
    
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}
Caution: Always call the superclass implementation of onSaveInstanceState() so the default implementation can save the state of the view hierarchy.

Restore Your Activity State


When your activity is recreated after it was previously destroyed, you can recover your saved state from the Bundle that the system passes your activity. Both the onCreate() and onRestoreInstanceState() callback methods receive the same Bundle that contains the instance state information.
Because the onCreate() method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it. If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed.
For example, here's how you can restore some state data in onCreate():


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); // Always call the superclass first
   
    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
        // Restore value of members from saved state
        mCurrentScore = savedInstanceState.getInt(STATE_SCORE);
        mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL);
    } else {
        // Probably initialize members with default values for a new instance
    }
    ...
}
Instead of restoring the state during onCreate() you may choose to implement onRestoreInstanceState(), which the system calls after the onStart() method. The system calls onRestoreInstanceState() only if there is a saved state to restore, so you do not need to check whether the Bundle is null:


public void onRestoreInstanceState(Bundle savedInstanceState) {
    // Always call the superclass so it can restore the view hierarchy
    super.onRestoreInstanceState(savedInstanceState);
   
    // Restore state members from saved instance
    mCurrentScore = savedInstanceState.getInt(STATE_SCORE);
    mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL);
}
Caution: Always call the superclass implementation of onRestoreInstanceState() so the default implementation can restore the state of the view hierarchy.
To learn more about recreating your activity due to a restart event at runtime (such as when the screen rotates), read Handling Runtime Changes.

diciembre 22, 2014

Primera prueba de codigo insertado

Para poder realizar anotaciones sobre los codigos de andrpid que iré ocupando más adelante decidí utilizar un método que me permita mostrar lo más fielmete posible la sintaxis de cada archivo es por eso que hoy e instalado el complemento de SyntaxHighlighter!! :)


#!/usr/bin/xml
 


      Tove
      Jani
      Reminder
      Don't forget me this weekend!

Sepadador con H1

#!/usr/bin/java
 
/* HelloWorld.java
 */
public class HelloWorld
{
 public static void main(String[] args) {
  System.out.println("Hello World!");
 }
}

junio 10, 2014

Getting things done with Google Apps, Jott & Salesforce.com

Our business has grown quickly over the past 18 months. One challenge has been finding the right system for email, schedules, to-dos and new business leads to handle our growth and keep things organized.
Here's what we've done so far to get organized, and what I'm looking at to make the system better:
  1. Getting Things DoneMy quest started when I read "Getting Things Done: The Art of Stress-Free Productivity" by David Allen. This book helped me radically reduce stress by dealing with all the loose ends that come into my life & business. Allen's book provided me with a system to process all "clutter" that used to rattle around in my mind -- even when I wasn't at the office. Prior to reading this book, I typically had 1,000 emails in my inbox -- many of which were in there because I thought I might need them in the future. Now that I've applied the principles in this book, my email inbox is completely empty most evenings when I leave the office. Best of all - I no longer wonder if I'm forgetting something, because everything is accounted for in my system. I now have a system to process everything -- whether it be email, calls I need to make, or even remembering to pick up a loaf of bread on my way home from work. This book is a must read for every small business owner.
  2. After reading the book and applying the system described above -- I found a "Getting Things Done" plug-in for Microsoft Outlook, which helped me process my email in a way that aligned with the principles in the book. However, we were switching things over to 100% Mac computers in our company, and MS Outlook was not easy to integrate with my new Mac. I needed to find a better way.
  3. GmailI tried several software options to replace Outlook, and finally settled on Gmail -- the web-based email powered by Google. At first I considered Gmail as a sub-par alternative to Outlook, that I was forced to use to streamline work on my Mac. However -- after less than a week of using Gmail, I started to realize its power and potential for my new system. I ended up importing 7,000 old email messages from Outlook that I'd archived over the past few years. Since Gmail is built on Google's powerful search engine, I can do an email search for "John Doe ABC Company" and in less than a second, Gmail searches my entire archive of mail and gives me results of every mail message where John Doe and ABC Company are mentioned in the same message. This has turned my email into a powerful database of archived "reference material" where I can find what I need in a matter of seconds.
  4. Click to view largerPeople tend to like Outlook because of the way it integrated Mail, Calendar & Tasks. Originally I feared I'd lose that integration when switching to Gmail. On the contrary, I was able to integrate Gmail with Google Calendar seamlessly, and then I found a powerful plug-in for Gmail called "Remember the Milk". With a couple of free plug-ins, my inbox has mail, calendar and to do items all on the same page -- like I had with Outlook. With a click or two, I can turn a mail message into a task, or attach it to a calendar item.
  5. JottFinally, I had to address the fact that I'd often think of things I needed to do while driving. I can send a text message from my cell phone and the message ends up on my to-do list -- but that isn't a safe option while driving. The problem was solved when I discovered Jott. With Jott's free service, I can call a toll-free number and speak my to-do items into the call. Jott automatically transcribes my speech to text, emails it to Gmail, and the item gets filtered onto my to-do list. It is wonderful!

    I setup my Jott account so I can create a to-do item, add a topic to my next staff meeting agenda, add an event to my calendar, and more. All by making a free phone call.

    A typical call to Jott goes something like this:

    JOTT: Who do you want to Jott?
    ME: Agenda
    JOTT: Agenda... is this correct?
    ME: Yes.
    JOTT: (beep)
    ME: Discuss the designers role on the new project from ABC Company
    JOTT: Got it.
    ME: (hang up)

    When I return to the office -- the voice message will have been transcribed to text - emailed to me, filtered to my "Meeting Agenda" list in Gmail, and removed from my inbox. I don't have to touch it, because it's not in my inbox any longer. But at the meeting on Monday, I'll bring up the list and there it is. It blows my mind that this service is free.
Phase two of the system begins Monday
I made all these changes, and it's helped me be a lot more productive. But as my productivity has increased, so has the number of new business leads coming into our business. I need a better system to track those prospective customers -- wherever they're at in the sales funnel.
I spent some time this weekend researching dozens of free open-source and paid options for CRM software to manage by sales prospects. I even loaded a couple of free options up and tried them out -- but most options felt clunky -- like a system that would complicate my work flow. If it's complicated, I won't use it.  (Nor should I).
Salesforce for Google AppsThe best choice appears to be a paid program -- SalesForce.com. The deal-breaker for me is the way they integrate with the suite of Google products that have helped my productivity so much. In fact, last Spring they rolled out a specially branded product: "Salesforce for Google Apps." I've setup a trial membership, and I'm giving it a 30-day test that begins Monday.
I'm optimistic that this will help keep everything integrated and will position our team for further growth. But I won't know how well Salesforce will work until I put it to work for us.

I'd love to hear what other small business owners are using -- what works and what doesn't. What works for us may not be ideal for another business. It all depends on what you're trying to accomplish. But if things aren't integrated and simple, it will never work. If you have ideas or questions, let's discuss them below, your comments are welcome.

junio 01, 2014

Scilab: un entorno de trabajo para realizar cálculos numéricos

Scilab es un entorno de trabajo para realizar cálculos numéricos destinados para ingenieros.
La herramienta contiene una gran cantidad de funciones matemáticas (puedes añadir las propias en formato C o Fortran) que se podrán mostrar en 2D o animarlas en 3D, o bien podrás crear simulaciones ODE y DAE.
Scilab es un Open Source disponible para Windows, Mac OS X y Linux.
Herramientas para estadísticas
Scilab

Renderman: La herramienta de animación comercial de Pixar gratis

Si algún día soñaste en ser un diseñador y animador de dibujos como los que muestran las películas de Pixar, ahora es tu oportunidad. Junto a una nueva versión de RenderMan, la compañía que creó éxitos como Buscando a Nemo, Cars, Ratatouille y más está ofreciendo una versión de suherramienta de animación gratis para uso no comercial que ya mismo puedes descargar.
El sello de estilo que dejaron películas como Toy Story y la mayoría de las que le siguieron a la saga dePixar es inconfundible. Diseños realistas con regordetes relieves  con un dejo de plastilina y un brillo que resalta cada pixel de la gesticulación maravillosa que tienen los personajes en mundos tridimensionales pintados con pasteles. Pixar Animation Studios es una marca, pero también un estilo, una manera de hacer las cosas. Parte de su toque especial está basado en el software de renderización de imágenes que utilizan, conocido como RenderMan. En un comunicado que pondrá felices a muchos animadores consagrados, estudiantes y curiosos, la compañía de Disney ha decidido renovar su RenderMan y darle a los usuarios una versión gratuita para uso personal.

RenderMan: La herramienta de animación de Pixar gratis para uso no comercial
RenderMan gratuito por fin

Previsto para su lanzamiento en la SIGGRAPH, Pixar anunció un cambio generacional en la versión 19 de RenderMan, buscando una restructuración con una interfaz modular y un nuevo paradigma de renderizado conocido como Sistema Integrador RenderMan (RIS). Esta nueva estructura será como un modo más optimizado para renderizar iluminación global, más específicamente para el seguimiento de rayos de luz con densa geometría. Ideal para objetos de pequeñas y grandes dimensiones, todo se hará en modo “single pass”. Compatible con Windows, Linux y Mac OS, el nuevo programa será de uso masivo en cuestión de días en tanto los usuarios se registren en el sitio dePixar a través del enlace al pie de la nota.

Como conmemoración de este renacimiento para el programa del cual salieron casi todas las películas de Disney Pixar, el estudio pondrá a disposición una versión de la herramienta de animación de Pixar gratis para uso no comercial. La licencia no comercial incluye el uso por estudiantes, para evaluaciones, aprendizaje personal o autodidacta, experimentación, investigación y para el desarrollo de herramientas y plug-ins de RenderMan. La versión comercial costará 500 dólares y tendrá como función exclusiva el renderizado por lotes entre otros paquetes de plugins y descuentos varios.