Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Unable to start activity ComponentInfo error

Unable to start activity ComponentInfo error

Put your problem here if it does not fit any of the other categories.

Unable to start activity ComponentInfo error

Postby hannon565 » Wed Apr 06, 2011 9:00 pm

I ve been doing this To Do list for past while well been stuck on this error for past while
Code: Select all
E/AndroidRuntime(25494): FATAL EXCEPTION: main
E/AndroidRuntime(25494): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.msd.assignment/com.msd.assignment.Details}: android.content.res.
Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime(25494):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
E/AndroidRuntime(25494):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
E/AndroidRuntime(25494):        at android.app.ActivityThread.access$2300(ActivityThread.java:135)
E/AndroidRuntime(25494):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
E/AndroidRuntime(25494):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(25494):        at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(25494):        at android.app.ActivityThread.main(ActivityThread.java:4914)
E/AndroidRuntime(25494):        at java.lang.reflect.Method.invokeNative(NativeMethod)
E/AndroidRuntime(25494):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(25494):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(25494):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(25494):        at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(25494): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime(25494):        at android.content.res.Resources.getText(Resources.java:201)
E/AndroidRuntime(25494):        at android.widget.TextView.setText(TextView.java:2828)
E/AndroidRuntime(25494):        at com.msd.assignment.Details.fillFields(Details.java:77)
E/AndroidRuntime(25494):        at com.msd.assignment.Details.onCreate(Details.java:43)
E/AndroidRuntime(25494):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
E/AndroidRuntime(25494):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
E/AndroidRuntime(25494):        ... 11 more


I've found that the error is with a line of code with i.putExtra(MyDBManager.KEY_ROWID, id);


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.msd.todo;
  2. //This is the main class of the application, where the list is displayed. Sorry for lack of comment feel its pretty self explanitory
  3.  
  4. import android.app.AlertDialog;
  5. import android.app.AlertDialog.Builder;
  6. import android.app.ListActivity;
  7. import android.content.DialogInterface;
  8. import android.content.Intent;
  9. import android.database.Cursor;
  10. import android.os.Bundle;
  11. import android.view.ContextMenu;
  12. import android.view.ContextMenu.ContextMenuInfo;
  13. import android.view.Menu;
  14. import android.view.MenuInflater;
  15. import android.view.MenuItem;
  16. import android.view.View;
  17. import android.widget.AdapterView.AdapterContextMenuInfo;
  18. import android.widget.ListView;
  19. import android.widget.SimpleCursorAdapter;
  20. import com.msd.assignment.MyDBManager;
  21.  
  22. public class Main extends ListActivity
  23. {
  24.         private MyDBManager dbHelper;
  25.         private static final int ACTIVITY_CREATE = 0;
  26.         private static final int ACTIVITY_EDIT = 1;
  27.         private static final int DELETE_ID = Menu.FIRST + 1;
  28.         private Cursor cursor;
  29.        
  30.     /** Called when the activity is first created. */
  31.     @Override
  32.     public void onCreate(Bundle savedInstanceState)
  33.     {
  34.         super.onCreate(savedInstanceState);
  35.         setContentView(R.layout.todo_list);
  36.         this.getListView().setDividerHeight(4);
  37.         dbHelper = new MyDBManager(this);
  38.         dbHelper.open();
  39.         fill();
  40.         registerForContextMenu(getListView());
  41.     }
  42.    
  43.     // Create the menu based on the XML defintion
  44.     public boolean onCreateOptionsMenu(Menu menu)
  45.     {
  46.         MenuInflater inflater = getMenuInflater();
  47.         inflater.inflate(R.menu.listmenu, menu);
  48.        
  49.         return true;
  50.     }
  51.    
  52.     public boolean onMenuItemSelected(int featureId, MenuItem item)
  53.     {
  54.         switch(item.getItemId())
  55.         {
  56.         case R.id.insert:
  57.                 createToDo();
  58.                 return true;
  59.         case R.id.help:
  60.                 openHelpDialog();
  61.                 return true;
  62.         }
  63.         return super.onMenuItemSelected(featureId,item);
  64.     }
  65.    
  66.     private void openHelpDialog()
  67.     {
  68.                 // TODO Auto-generated method stub
  69.         Builder dialog = new AlertDialog.Builder(this);
  70.         dialog.setTitle("HELP");
  71.         dialog.setMessage("To delete a ToDo\n long click on the item you want to delete.\n Press menu and select add todo\n to make a new todo");
  72.         dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  73.                        
  74.                         @Override
  75.                         public void onClick(DialogInterface dialog, int which)
  76.                         {
  77.                                 // TODO Auto-generated method stub
  78.                                
  79.                         }
  80.                 });
  81.         dialog.show();
  82.                
  83.         }
  84.  
  85.         public boolean onOptionsItemSelected(MenuItem item)
  86.     {
  87.         switch(item.getItemId())
  88.         {
  89.         case R.id.insert:
  90.                 createToDo();
  91.                 return true;
  92.         }
  93.        
  94.         return super.onOptionsItemSelected(item);
  95.     }
  96.    
  97.     public boolean onContextItemSelected(MenuItem item)
  98.     {
  99.         switch(item.getItemId())
  100.         {
  101.         case DELETE_ID:
  102.                 AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  103.                 dbHelper.deleteToDo(info.id);
  104.                 fill();
  105.                 return true;
  106.         }
  107.        
  108.         return super.onContextItemSelected(item);
  109.     }
  110.    
  111.         private void createToDo()
  112.         {
  113.                 Intent i = new Intent(this, Details.class);
  114.                 startActivityForResult(i, ACTIVITY_CREATE);
  115.         }
  116.        
  117.         //ListView and view (row) on which was clicked and position
  118.        
  119.         protected void onListItemClick(ListView l, View v, int position, long id)
  120.         {
  121.                 super.onListItemClick(l, v, position, id);
  122.                 Intent i = new Intent(this, Details.class);
  123.                 i.putExtra(MyDBManager.KEY_ROWID, id);
  124.                
  125.                 //Activity returns as result if called with startActivityForResult
  126.                
  127.                 startActivityForResult(i, ACTIVITY_EDIT);
  128.         }
  129.        
  130.         protected void onActivityResult(int requestCode, int resultCode, Intent intent)
  131.         {
  132.                 super.onActivityResult(requestCode, resultCode, intent);
  133.                 fill();
  134.         }
  135.  
  136.         private void fill()
  137.         {
  138.                 cursor = dbHelper.getAllToDo();
  139.                 startManagingCursor(cursor);
  140.                
  141.                 String[] from = new String[] { MyDBManager.KEY_SUMMARY };
  142.                 int[] to = new int[] {R.id.label};
  143.                
  144.                 //Create array adapter and set it to display using the todo_row
  145.                 SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
  146.                                 R.layout.todo_row, cursor, from, to);
  147.                 setListAdapter(notes);
  148.         }
  149.        
  150.         public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
  151.         {
  152.                 super.onCreateContextMenu(menu, v, menuInfo);
  153.                 menu.add(0, DELETE_ID, 0, R.string.menu_delete);
  154.         }
  155. }
Parsed in 0.022 seconds, using GeSHi 1.0.8.4



This class is where all the details of the todo will be shown or edited.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.msd.todo;
  2.  
  3. import android.app.Activity;
  4. import android.database.Cursor;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.Spinner;
  11. import com.msd.assignment.MyDBManager;
  12.  
  13. public class Details extends Activity
  14. {
  15.  
  16.                 private EditText title;
  17.                 private EditText body;
  18.                 private Long    rowId;
  19.                 private MyDBManager db;
  20.                 private Spinner category;
  21.                
  22.                 protected void onCreate(Bundle bundle)
  23.                 {
  24.                         super.onCreate(bundle);
  25.                         db = new MyDBManager(this);
  26.                         db.open();
  27.                         setContentView(R.layout.todo_edit);
  28.                         category =(Spinner) findViewById(R.id.category);
  29.                         title = (EditText) findViewById(R.id.edit_title);
  30.                         body = (EditText) findViewById(R.id.edit_description);
  31.                        
  32.                         Button confirm = (Button) findViewById(R.id.edit_confirm);
  33.                        
  34.                         rowId = null;
  35.                         Bundle extras = getIntent().getExtras();
  36.                         rowId = (bundle == null) ? null : (Long) bundle.getSerializable(MyDBManager.KEY_ROWID);
  37.                        
  38.                         if(extras != null)
  39.                         {
  40.                                 rowId = extras.getLong(MyDBManager.KEY_ROWID);
  41.                         }
  42.                        
  43.                         fillFields();
  44.                         confirm.setOnClickListener(new View.OnClickListener()
  45.                         {
  46.                                
  47.                                 @Override
  48.                                 public void onClick(View v)
  49.                                 {
  50.                                         // TODO Auto-generated method stub
  51.                                         setResult(RESULT_OK);
  52.                                         finish();
  53.                                        
  54.                                 }
  55.                         });
  56.                 }
  57.  
  58.                 private void fillFields()
  59.                 {
  60.                         // TODO Auto-generated method stub
  61.                         if(rowId != null)
  62.                         {
  63.                                 Cursor todo = db.getToDO(rowId);
  64.                                 startManagingCursor(todo);
  65.                                 String mCategory = todo.getString(todo.getColumnIndexOrThrow(MyDBManager.KEY_CATEGORY));
  66.                                 for(int i = 0; i<category.getCount(); i++)
  67.                                 {
  68.                                         String s = (String) category.getItemAtPosition(i);
  69.                                         Log.e(null, s + " " + mCategory);
  70.                                         if(s.equalsIgnoreCase(mCategory))
  71.                                         {
  72.                                                 category.setSelection(i);
  73.                                         }
  74.                                        
  75.                                 }
  76.                                
  77.                                 title.setText(todo.getShort(todo.getColumnIndexOrThrow(MyDBManager.KEY_SUMMARY)));
  78.                                 body.setText(todo.getString(todo.getColumnIndexOrThrow(MyDBManager.KEY_DESCRIPTION)));
  79.                                
  80.                         }
  81.                        
  82.                 }
  83.                
  84.                 protected void onSaveInstanceState(Bundle outState)
  85.                 {
  86.                         super.onSaveInstanceState(outState);
  87.                         saveState();
  88.                         outState.putSerializable(MyDBManager.KEY_ROWID, rowId);
  89.                        
  90.                 }
  91.                
  92.                 protected void onPause()
  93.                 {
  94.                         super.onPause();
  95.                         saveState();
  96.                 }
  97.                
  98.                 protected void onResume()
  99.                 {
  100.                         super.onResume();
  101.                         fillFields();
  102.                 }
  103.                
  104.                 private void saveState()
  105.                 {
  106.                         String mCategory = (String) category.getSelectedItem();
  107.                         String mTitle = (String) title.getText().toString();
  108.                         String description = body.getText().toString();
  109.                        
  110.                         if(rowId == null)
  111.                         {
  112.                                 long id = db.createToDo(mCategory, mTitle, description);
  113.                                 if(id>0)
  114.                                 {
  115.                                         rowId = id;
  116.                                 }
  117.                                
  118.                         }
  119.                        
  120.                         else
  121.                         {
  122.                                 db.updateToDO(rowId, mCategory, mTitle, description);
  123.                         }
  124.                 }
  125. }
  126.  
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


AndroidManifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.      package="com.msd.assignment"
  4.      android:versionCode="1"
  5.      android:versionName="1.0">
  6.  
  7.  
  8.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  9.         <activity android:name=".Main"
  10.                  android:label="@string/app_name">
  11.             <intent-filter>
  12.                 <action android:name="android.intent.action.MAIN" />
  13.                 <category android:name="android.intent.category.LAUNCHER" />
  14.             </intent-filter>
  15.         </activity>
  16.         <activity android:name=".Details"></activity>
  17.        
  18.     </application>
  19. </manifest>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Sorry if this problem has risien up before i just couldnt find one with the same problem that had been solved.
I'll include the database code or xml files if needed
hannon565
Junior Developer
Junior Developer
 
Posts: 15
Joined: Sun Mar 20, 2011 11:40 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 11 guests