[android-beginners] Application crashing

2010-06-23 Thread Varun Khanduja
Hello,

I am trying to make a small To do list application. The application
keeps crashing on and saying, the application closed and please try
again. The message also has force close option.

Here is the code, does anyone has an idea what's wrong?

Thanks

package com.todolist;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

public class todolist extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
// Inflate your view
setContentView(R.layout.main);
// Get references to UI widgets
ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText =
(EditText)findViewById(R.id.myListView);

// Create the array list of to do items
final ArrayListString todoItems = new ArrayListString();
// Create the array adapter to bind the array to the listview
final ArrayAdapterString aa; aa = new
ArrayAdapterString(this,


android.R.layout.simple_list_item_1,

todoItems);
// Bind the array adapter to the listview.
myListView.setAdapter(aa);
myEditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
todoItems.add(0, myEditText.getText().toString());
aa.notifyDataSetChanged(); myEditText.setText();
return true;
} return false;
} });
}
}

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Application crashing

2010-06-23 Thread Mark Murphy
On Wed, Jun 23, 2010 at 1:28 PM, Varun Khanduja varunkhand...@gmail.com wrote:
 I am trying to make a small To do list application. The application
 keeps crashing on and saying, the application closed and please try
 again. The message also has force close option.

 Here is the code, does anyone has an idea what's wrong?

Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine
the Java stack trace associated with your crash, so you can see where
in your code the problem occurs.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Application crashing

2010-06-23 Thread Simon Platten

Hi,

Your onCreate method is not calling the default:

super.onCreate( icicle );

Also, I would wrap the body of the code in a try{ } catch( Exception ex 
) clause.


Hope this helps,
Sy




Varun Khanduja wrote:

Hello,

I am trying to make a small To do list application. The application
keeps crashing on and saying, the application closed and please try
again. The message also has force close option.

Here is the code, does anyone has an idea what's wrong?

Thanks

package com.todolist;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

public class todolist extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
// Inflate your view
setContentView(R.layout.main);
// Get references to UI widgets
ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText =
(EditText)findViewById(R.id.myListView);

// Create the array list of to do items
final ArrayListString todoItems = new ArrayListString();
// Create the array adapter to bind the array to the listview
final ArrayAdapterString aa; aa = new
ArrayAdapterString(this,


android.R.layout.simple_list_item_1,

todoItems);
// Bind the array adapter to the listview.
myListView.setAdapter(aa);
myEditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
todoItems.add(0, myEditText.getText().toString());
aa.notifyDataSetChanged(); myEditText.setText();
return true;
} return false;
} });
}
}

  


--
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Application crashing

2010-06-23 Thread Justin Anderson
One other thing to mention... These groups are not only great for posting
questions but also for searching through them to find other posts with the
same problem or question that may already have an answer.

In particular, your question is one that has been answered many times over
and a quick search for Force Close or Crash probably would have given
you several posts with the same answers that Mark and Simon gave.

Not only does it prevent the group from getting bloated with duplicate
questions, it can also help improve your development time because you don't
have to constantly wait for responses to your questions.

Thanks,
Justin

--
There are only 10 types of people in the world...
Those who know binary and those who don't.
--


On Wed, Jun 23, 2010 at 11:41 AM, Mark Murphy mmur...@commonsware.comwrote:

 On Wed, Jun 23, 2010 at 1:28 PM, Varun Khanduja varunkhand...@gmail.com
 wrote:
  I am trying to make a small To do list application. The application
  keeps crashing on and saying, the application closed and please try
  again. The message also has force close option.
 
  Here is the code, does anyone has an idea what's wrong?

 Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine
 the Java stack trace associated with your crash, so you can see where
 in your code the problem occurs.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_
 Version 1.6 Available!

 --
 You received this message because you are subscribed to the Google
 Groups Android Beginners group.

 NEW! Try asking and tagging your question on Stack Overflow at
 http://stackoverflow.com/questions/tagged/android

 To unsubscribe from this group, send email to
 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-beginners?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Application Crashing OutOfMemory .Restructuring Help Needed

2010-03-22 Thread Alok Kulkarni
Hi guys,
I have an application which fetches data from server and shows it in
different lists in my application.
I used the adb shell procrank command to find out the memory usage of my
application
It takes 10 mb for the UI (I have a single Activity ,but many layout files),
And the data which comes from the server is stored in memory arrays for
logical representation  on UI (As well as database)and it takes 6 mb of the
memory .So  application's runtime size reaches to 16 mb and then many a
times its crashing after that with OutOfMemoryException.
Another major problem is that later for the next client release , the data
comming from the server will be around 12 mb.. :( :( So i need to do a major
restructuring in the App.I beleive that i cannot increase my App size from
16 mb to more
So my question here is , can i have two seperate applications , one of which
will fetch the data from the server and keep it in memory as well as
database and another App will be used for showing the UI and it will do an
inter Application communication to fetch the data and display it on the UI
in this App.
So the 1st App wil be a backgrond App which will handle Server communication
as well as data storage , the second App will start this 1st App .
Thanks,Alok.

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.