I am learning ActivityLifeCycle from
http://developer.android.com/training/basics/activity-lifecycle/stopping.html and getting message while running the code "Unfortunately ActiviyLifeCycle has stopped" and I want to know what is Notepad.Notes in values.put(Notepad.Notes.COLUMN_NAME_NOTE, getCurrentNoteText()); how to resolve this issue
Below is the code
**ActivityLifeCycle.java**
package com.example.activitylifecycle;
import android.content.ContentValues;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.TextView;
import android.content.Context;
import android.content.ClipData;
public class MainActivity extends ActionBarActivity {
TextView mTextView; //Member TextView
private Uri mUri;
private int mCurrentScore, mCurrentLevel;
static final String STATE_SCORE = "playerScore";
static final String STATE_LEVEL = "playerLevel";
/*private static final int COLUMN_NAME_NOTE=0;
private static final int COLUMN_NAME_TITLE=1;*/
@Override
protected void onCreate(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);
super.onCreate(savedInstanceState);
// 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
}
// Set the user interface layout for this Activity
// The layout file is defined in the project res/layout/main_activity.xml file
setContentView(R.layout.activity_main);
// Initialize member TextView so we can manipulate it later
mTextView = (TextView) findViewById(R.id.text_message);
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// For the main activity, make sure the icon in the action bar
// does not behave as a button
android.app.ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
}
}
public void OnRestoreInstanceState(Bundle savedInstanceState){
//Always call the superclass so it can restore the vie hierarchy
super.onRestoreInstanceState(savedInstanceState);
//Restore state members for state instance
mCurrentScore = savedInstanceState.getInt(STATE_SCORE);
mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL);
}
@Override
public void onDestroy() {
super.onDestroy(); // Always call the superclass
// Stop method tracing that the activity started during onCreate()
android.os.Debug.stopMethodTracing();
}
@Override
protected void onStop(){
super.onStop(); //Always call superclass method 1st
//Save note current draft and we want to be sure current note's progress isn't lost
ContentValues values = new ContentValues();
values.put(Notepad.Notes.COLUMN_NAME_NOTE, getCurrentNoteText());
values.put(Notepad.Notes.COLUMN_NAME_TITLE, getCurrentNoteTitle());
getContentResolver().update(
mUri, // Uri for the Note to Update
values, // The map of column name and new values apply to them
null, // No select criteria are used
null // No where column are used
);
}
@Override
protected void onStart() {
super.onStart(); // Always call the superclass method first
// The activity is either being restarted or started for the first time
// so this is where we should make sure that GPS is enabled
LocationManager locationManager =
(LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!gpsEnabled) {
// Create a dialog here that requests the user to enable GPS, and use an intent
// with the android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS action
// to take the user to the Settings screen to enable GPS when they click "OK"
}
}
@Override
protected void onRestart() {
super.onRestart(); // Always call the superclass method first
// Activity being restarted from stopped state
}
}
**Notepad.java**
package com.example.activitylifecycle;
public class Notepad {
public class Notes {
public static final String COLUMN_NAME_NOTE = "note";
public static final String COLUMN_NAME_TITLE = "title";
}
}