[android-developers] Re: Null Pointer Exception In Method Boolean.Org.Json.Jsonobject Do in background async task

2016-06-25 Thread Abeer Shlby

>
> I get this error End of input at character 0 of 
> after i run code below as you mention before
>
 try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/630cb522-4892-44b8-8aab-8aa008a9170f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Null pointer exception in sending SMS..

2011-11-29 Thread Ali Chousein
Check your logcat. It'll give you very good log information where
exactly (e.g. on which exact line) you are getting the null pointer
exception.

-
Ali Chousein
Weather-Buddy
http://weatherbuddy.blogspot.com | http://twitter.com/weather_buddy
Geo-Filtered Assistant
http://geo-filtered-assistant.blogspot.com
https://marketplace.cisco.com/apphq/store/products/994

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Null pointer exception in sending SMS..

2011-11-29 Thread Rocky
Provide the logcat/error.

On Tue, Nov 29, 2011 at 3:18 PM, Ali Chousein ali.chous...@gmail.comwrote:

 Check your logcat. It'll give you very good log information where
 exactly (e.g. on which exact line) you are getting the null pointer
 exception.

 -
 Ali Chousein
 Weather-Buddy
 http://weatherbuddy.blogspot.com | http://twitter.com/weather_buddy
 Geo-Filtered Assistant
 http://geo-filtered-assistant.blogspot.com
 https://marketplace.cisco.com/apphq/store/products/994

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Thanks  Regards

Rakesh Kumar Jha
Android Developer, Trainer and Mentor
Bangalore
(O) +918030274295
(R) +919886336619

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Null pointer exception in sending SMS..

2011-11-29 Thread Gergely Juhász
0. Read the docs:
http://developer.android.com/reference/android/telephony/gsm/SmsManager.html
1. Check the official example:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/os/index.html
2.Set the second argument to null in
  sms.sendTextMessage(phoneNumber,  , msg, sentPI, deliveredPI);3.
Be sure that msg is not empty. (TextUtils.isEmpty is helpfull)
4. Be sure you have the android.permission.SEND_SMS permission
4. How would you like to unregister that broadcast receiver?
5. Improve your skills

Yeah and you can not live without logcat in the android world:
http://developer.android.com/guide/developing/tools/logcat.html

On 29 November 2011 11:00, Rocky rkjhaw1...@gmail.com wrote:
 Provide the logcat/error.


 On Tue, Nov 29, 2011 at 3:18 PM, Ali Chousein ali.chous...@gmail.com
 wrote:

 Check your logcat. It'll give you very good log information where
 exactly (e.g. on which exact line) you are getting the null pointer
 exception.

 -
 Ali Chousein
 Weather-Buddy
 http://weatherbuddy.blogspot.com | http://twitter.com/weather_buddy
 Geo-Filtered Assistant
 http://geo-filtered-assistant.blogspot.com
 https://marketplace.cisco.com/apphq/store/products/994

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




 --
 Thanks  Regards

 Rakesh Kumar Jha
 Android Developer, Trainer and Mentor
 Bangalore
 (O) +918030274295
 (R) +919886336619


 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: null pointer exception

2011-07-12 Thread Justin Anderson
* connectivity.getActiveNetworkInfo() returns null if there is no
connection.
Hence when you call .isConnected() on that, it throws null pointer
exception.*

No, that is not it... He checks to make sure that
connectivity.getActiveNetworkInfo() is not null before he calls the other
methods...

What does logcat say exactly regarding the null pointer exception?
 Specifically look for a caused by line...  Also, I would probably do
something like this, but that is just coding preferences (though, it might
help you get better info from logcat on the cause of the error):

NetworkInfo netInfo = connectivity.getActiveNetworkInfo();
boolean valid = netInfo != null  netInfo.isAvailable() 
netInfo.isConnected();

Have you made sure that your connectivity variable is not null?

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Tue, Jul 5, 2011 at 10:33 PM, Sourav Howlader
sourav.howla...@gmail.comwrote:

 Hi vani,

 connectivity.getActiveNetworkInfo() returns null if there is no
 connection.
 Hence when you call .isConnected() on that, it throws null pointer
 exception.

 Regards,
 Sourav

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: null pointer exception

2011-07-05 Thread Sourav Howlader
Hi vani,

connectivity.getActiveNetworkInfo() returns null if there is no
connection.
Hence when you call .isConnected() on that, it throws null pointer
exception.

Regards,
Sourav

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Null Pointer Exception on accessing value of EditText

2011-05-21 Thread Ankur Kumar

Thanks for the help TreKing and Gaurav!

On May 21, 12:14 am, gaurav gupta gaurav.gupta...@gmail.com wrote:
 First set any value in edittext then u can get value .

    1.  EditText IPInput = (EditText)
 findViewById(R.id.ip);
 iPinput.setText(Value inserted successfully);
                        2.  IPInput.getText().toString();
 System.out.println(ip);
                        3.  System.out.println(IPInput.getText().toString());







 On Sat, May 21, 2011 at 12:40 AM, TreKing treking...@gmail.com wrote:
  On Thu, May 19, 2011 at 4:16 PM, Ankur Kumar specialan...@gmail.comwrote:

   I am getting java.lang.NullPointerException at step 3 in my code. Have
  not been able to figure this out.

  1 - Use your debugger.
  2 - Figure out what is null.
  3 - Make it not null.

  --- 
  --
  TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
  transit tracking app for Android-powered devices

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Null Pointer exception in Location Manager

2010-09-29 Thread Gold
Hi,,


 Finally i got the solution..!

The mistakes are 1) I am not assign port to telnet
  2) Add uses permission for
mock location..now i got latitude..



Thanks  Warm Regards,
Gold

On Sep 29, 2:11 am, TreKing treking...@gmail.com wrote:
 On Tue, Sep 28, 2010 at 4:09 PM, Gold thangadura...@gmail.com wrote:
  hi..

  No ,  still i am checking, Now while loading home
  screen itself thorw the error
  The application stopped unexpectly in log also i get same error null
  pointer exception

  thanks  warm regards,
  gold

 A) Please respond to the group
 B) Again, use your debugger to step through your code around where it's
 throwing the exception. This should tell you EXACTLY what's null. The rest
 of us are not going to be able to debug your program for you like this.

 -
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread Gold
Hi..Sorry,


   Herewith I attached Logcat trace..!


09-29 02:09:42.266: DEBUG/AndroidRuntime(2979): 
AndroidRuntime START 
09-29 02:09:42.276: DEBUG/AndroidRuntime(2979): CheckJNI is ON
09-29 02:09:42.536: DEBUG/AndroidRuntime(2979): --- registering native
functions ---
09-29 02:09:43.456: DEBUG/AndroidRuntime(2979): Shutting down VM
09-29 02:09:43.456: DEBUG/dalvikvm(2979): Debugger has detached;
object registry had 1 entries
09-29 02:09:43.486: INFO/AndroidRuntime(2979): NOTE: attach of thread
'Binder Thread #3' failed
09-29 02:09:44.056: DEBUG/AndroidRuntime(2987): 
AndroidRuntime START 
09-29 02:09:44.056: DEBUG/AndroidRuntime(2987): CheckJNI is ON
09-29 02:09:44.286: DEBUG/AndroidRuntime(2987): --- registering native
functions ---
09-29 02:09:45.306: INFO/ActivityManager(59): Starting activity:
Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x1000
cmp=com.sample.test/.Starter }
09-29 02:09:45.476: DEBUG/AndroidRuntime(2987): Shutting down VM
09-29 02:09:45.526: DEBUG/dalvikvm(2987): Debugger has detached;
object registry had 1 entries
09-29 02:09:45.606: INFO/AndroidRuntime(2987): NOTE: attach of thread
'Binder Thread #3' failed
09-29 02:09:45.616: INFO/ActivityManager(59): Start proc
com.sample.test for activity com.sample.test/.Starter: pid=2995
uid=10040 gids={3003}
09-29 02:09:46.466: INFO/ActivityManager(59): Starting activity:
Intent { cmp=com.sample.test/.Home }
09-29 02:09:46.596: WARN/GpsLocationProvider(59): Duplicate add
listener for uid 10040
09-29 02:09:46.606: DEBUG/AndroidRuntime(2995): Shutting down VM
09-29 02:09:46.606: WARN/dalvikvm(2995): threadid=1: thread exiting
with uncaught exception (group=0x4001d800)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): FATAL EXCEPTION: main
09-29 02:09:46.636: ERROR/AndroidRuntime(2995):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.sample.test/com.sample.test.Home}:
java.lang.NullPointerException
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2663)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2679)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.os.Looper.loop(Looper.java:123)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread.main(ActivityThread.java:4627)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
java.lang.reflect.Method.invokeNative(Native Method)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
java.lang.reflect.Method.invoke(Method.java:521)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
dalvik.system.NativeStart.main(Native Method)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): Caused by:
java.lang.NullPointerException
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
com.sample.test.Home.onCreate(Home.java:38)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2627)
09-29 02:09:46.636: ERROR/AndroidRuntime(2995): ... 11 more
09-29 02:09:46.646: WARN/ActivityManager(59):   Force finishing
activity com.sample.test/.Home
09-29 02:09:47.156: WARN/ActivityManager(59): Activity pause timeout
for HistoryRecord{44095e38 com.sample.test/.Home}
09-29 02:09:57.664: WARN/ActivityManager(59): Activity destroy timeout
for HistoryRecord{44089b28 com.sample.test/.Starter}
09-29 02:09:57.675: WARN/ActivityManager(59): Activity destroy timeout
for HistoryRecord{44095e38 com.sample.test/.Home}
09-29 02:10:01.025: INFO/Process(2995): Sending signal. PID: 2995 SIG:
9
09-29 02:10:01.045: INFO/ActivityManager(59): Process com.sample.test
(pid 2995) has died.
09-29 02:10:01.045: WARN/GpsLocationProvider(59): Unneeded remove
listener for uid 1000
09-29 02:10:01.105: WARN/InputManagerService(59): Window already
focused, ignoring focus gain of:
com.android.internal.view.iinputmethodclient$stub$pr...@43f49530


On Sep 29, 1:36 am, TreKing treking...@gmail.com wrote:
 On Tue, Sep 28, 2010 at 3:33 PM, Gold thangadura...@gmail.com wrote:
  I tried but it will show Null pointer exception.

 Where? What's the stack trace?

 

Re: [android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread TreKing
On Tue, Sep 28, 2010 at 3:41 PM, Gold thangadura...@gmail.com wrote:

 09-29 02:09:46.636: ERROR/AndroidRuntime(2995): Caused by:
 java.lang.NullPointerException
 09-29 02:09:46.636: ERROR/AndroidRuntime(2995): at
 com.sample.test.Home.onCreate(Home.java:38)


Now which part of your code is at line 38?

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread Gold
Hi..

   While clicking the button1 that is
  redbtn.setOnClickListener(new
OnClickListener()
{

@Override
public void onClick(View v)
{

Toast.makeText(getBaseContext(),
Latitude : +
latitude.toString(), Toast.LENGTH_SHORT).
show();
}
});

Here it will show the exception


On Sep 29, 1:45 am, TreKing treking...@gmail.com wrote:
 On Tue, Sep 28, 2010 at 3:41 PM, Gold thangadura...@gmail.com wrote:
  09-29 02:09:46.636: ERROR/AndroidRuntime(2995): Caused by:
  java.lang.NullPointerException
  09-29 02:09:46.636: ERROR/AndroidRuntime(2995):     at
  com.sample.test.Home.onCreate(Home.java:38)

 Now which part of your code is at line 38?

 -
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread TreKing
On Tue, Sep 28, 2010 at 3:49 PM, Gold thangadura...@gmail.com wrote:

 While clicking the button1 that is


Step through the debugger through this point and inspect the values of your
variables in the click listener. This will tell you exactly what's null in
there.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread Gold

Hi,,

 If i click redbutton I need to display latitude
 if i click greenbutton i need to display longitude

How can i did that..! please give any solution..!


On Sep 29, 1:44 am, Kostya Vasilyev kmans...@gmail.com wrote:
 Your code doesn't seem to assign any values to redbtn and greenbtn.

 Then you call methods on these objects - perhaps they are still Null at that
 point?

 --
 Kostya Vasilyev --http://kmansoft.wordpress.com

 29.09.2010 0:34 пользователь Gold thangadura...@gmail.com написал:

 Hi..All,

                    I need to disply  current Position latitude and
 logintude .. I tried but it will show Null pointer exception.. here
 with i attached my code... please help me to solve this problem..
 I run this application on android emulator

 import android.app.Activity;
 import android.app.Dialog;
 import android.content.Context;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.location.LocationProvider;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.Toast;

 public class Home extends Activity
 {
        private Button btn1;
        private Button btn2;
        private Button btn3;
        private LocationListener myLocationListener;
        private LocationManager myLocationManager;
        public String latitude;
        public String longitude;

        /** Called when the activity is first created. */
   �...@override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);

        myLocationManager =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        myLocationListener = new MyLocationListener();

 myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
 1, 1, myLocationListener);

 latitude=String.valueOf(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude());
                longitude =
 String.valueOf(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude());

                btn1= (Button)findViewById(R.id.btn1);
                btn2= (Button)findViewById(R.id.btn2);
                btn3= (Button)findViewById(R.id.btn3);

                redbtn.setOnClickListener(new OnClickListener()
                {

                       �...@override
                        public void onClick(View v)
                        {

                                Toast.makeText(getBaseContext(), Latitude :
 +
 latitude.toString(), Toast.LENGTH_SHORT).show();
                        }
                });

                greenBtn.setOnClickListener(new OnClickListener()
                {

                       �...@override
                        public void onClick(View v) {
                                // TODO Auto-generated method stub
                                Toast.makeText(getBaseContext(), Longitude:
 +
 longitude.toString(), Toast.LENGTH_SHORT).show();
                        }
                });

                cancelBtn.setOnClickListener(new OnClickListener() {

                       �...@override
                        public void onClick(View v)
                        {
                                // TODO Auto-generated method stub
                                Toast.makeText(Home.this, NO gps,
 Toast.LENGTH_SHORT).show();

                        }
                });

        }

         public class MyLocationListener implements LocationListener
         {
                        public void onLocationChanged(Location argLocation)
                        {
                                if(argLocation != null)
                                {
                                        latitude =
 String.valueOf(argLocation.getLatitude());
                            longitude =
 String.valueOf(argLocation.getLongitude());
                        }
                        }
                    public void onProviderDisabled(String provider)
                    {
                    }
                public void onProviderEnabled(String provider)
                {
                }

                    public void onStatusChanged(String provider, int status,
 Bundle
 arg2)
                    {
                    }

        };

 }

 Thanks  Warm Regards,
 gold

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers 

Re: [android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread TreKing
On Tue, Sep 28, 2010 at 4:00 PM, Gold thangadura...@gmail.com wrote:

  If i click redbutton I need to display latitude
 if i click greenbutton i need to display longitude


OK. Does this mean you fixed your null pointer problem?


  How can i did that..! please give any solution..!


Do what? Solution to what? Clicking buttons? Getting lat / long? Displaying
to where? On a map? On the screen? On a button? In the logs?

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null Pointer exception in Location Manager

2010-09-28 Thread TreKing
On Tue, Sep 28, 2010 at 4:09 PM, Gold thangadura...@gmail.com wrote:

 hi..

 No ,  still i am checking, Now while loading home
 screen itself thorw the error
 The application stopped unexpectly in log also i get same error null
 pointer exception


 thanks  warm regards,
 gold



A) Please respond to the group
B) Again, use your debugger to step through your code around where it's
throwing the exception. This should tell you EXACTLY what's null. The rest
of us are not going to be able to debug your program for you like this.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null Pointer Exception with getIntent().Extras....

2010-01-09 Thread Albert
thanks is working now, it was exactly what you said, I was looking
into Intent and put/get Extras...
I had no clue of this PendingIntent behavior.

On Jan 9, 10:06 pm, Mark Murphy mmur...@commonsware.com wrote:
 Albert wrote:
  Hi,

  Can someone see what I am doing wrong here, when I try to get the
  extras I sent on my intent it always returns null

  Intent activityIntent = new Intent(context, TopImage.class);
  activityIntent.putStringArrayListExtra(com.mobile.dev.LIST,
  mStringList);  //mStringList is not null for sure
                                                                              
                                   //
  com.mobile.dev.LIST my package prefix+keyname
  then to extract the data:

  //this is done in onCreate()
  ArrayListString t = new ArrayListString();
  t = getIntent().getStringArrayListExtra(com.mobile.dev.LIST);  // it
  is always returns null, I get an null pointer exception as soon as I
  use t.

  The intent is sent from a widget which launches the activity from
  which i am trying to get this Extra...

 If you are wrapping this in a PendingIntent, that may be the source of
 your difficulty. Make sure your previous PendingIntent is canceled
 before creating a new one with a new extra.

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

 Android Training in US: 8-12 February 2010:http://bignerdranch.com
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null pointer exception

2010-01-06 Thread JasonMP
That was it!  I took out the startManagingCursor() and it worked
fine.  My next question is what should I do to handle the life cycle
of my cursor?  Should I close it outside the switch statement?

On Jan 5, 5:41 pm, Vladimir vladimir.funti...@gmail.com wrote:
 What do you think about this:
 1. Cursor created in onContextItemSelected() is null (for some reason)
 2. Since its lifecycle is managed by the activity (startManagingCursor
 (c)), it tries to release it when the activity is stopped (when the
 new intent is launched)
 3. It doesn't expect managed cursor to be null and crashes (at
 android.app.Activity.performStop(Activity.java:3604))
 Does that make sense? I have little idea about how this cursor
 management works, but I would do the following:
 1. Try removing startManagingCursor() calls to see if these are
 related
 2. Double check if the cursor is null
 3. Take a look inside Android source and specifically Activity.java:
 3604
 Just a guess :)

 On Jan 5, 4:02 pm, JasonMP hyperje...@gmail.com wrote:



  Ok, I tried gino's idea with initializing my arrays differently.  I
  also changed there names so that they did not share a name with any
  other arrays in my app:  Did not work.

  I also tried calling to static variables instead of passing variables
  between classes with intents:  This also did not work.

  I can't determine which line of code causes the error.  The logcat
  does not give me a pointer to anything in my app at all.  I tried to
  narrow it down with breakpoints and logging and what I found is that
  it runs through all of my code without a hitch, and then once its done
  it throws the exception.

  And again the exception only happens when I call the intent from a
  contextMenu.

  On Jan 1, 2:56 am, Wiebbe wie...@gmail.com wrote:

   Shouldnt you check if the bundle is null or not? Try to loop through
   it when you get there from a onContextItemSelected event. I'm guessing
   some value somewhere is null when it should be instantiated. Perhaps
   the intent is started quicker or without the bundle somehow so you get
   a nullpointer exception?

   On 31 dec 2009, 15:57, JasonMP hyperje...@gmail.com wrote:

yes, Select.class is another one of my files.  throughout my app there
are a few different calls to it, all done the same way i.e. Intent i
= new Intent(this, Select.class); startActivity(i);

No where in Select.class do I make a call to start Select.class or
Sheet.class.  When its done it calls finish();

in the onCreate() of Select.class I grab the extras from the invoking
class with this line of code:

public class Select extends ListActivity{

        DBAdapter db = new DBAdapter(this);
        String slotName = null;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);

                  db.open();

                  ListView list = getListView();

                  View v = View.inflate(this, R.layout.list_header, 
null);
                  list.addHeaderView(v, null, false);

                  name = 
this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
        }

Could it be something in the .getIntent() method?  or
the .getStringExtra()?

On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
wrote:

 Now that I understand your intent creation a little better, and I see 
 that
 the intent you are creating is unique from the class in which the code
 exists, I am not quite sure how it could be an infinite loop in the
 (immediate) way I was thinking.

 Reading this code

 Intent i = new Intent(this, Select.class);

 I have to start thinking there's something wrong with this.  I tried 
 to look
 up the Select class on the android developers site, and couldn't 
 find it.
 Is that a class from another of your files?  I guess I would wonder 
 if the
 code being invoked there, is somehow causing this class to be 
 invoked, thus
 causing some kind of loop.  I would grep for any reference to your 
 Sheet
 class, from anywhere else in your code, and that would likely be 
 suspect.

 In general, the below is kind of a side topic, to maybe help you with
 generic debugging.

 All the Best, Steve.

 *Ok... the only thing I can think to really help you is to start 
 taking
 advantage of logging.  In your import list, I see you don't include 
 the
 logger code, so maybe you can give this a shot.

 1) in the import list

 import android.util.Log;

 2) and throughout your code

 Log.d( TAG, DebugText );

 where TAG is a string that is unique to you, and DebugText is 
 something
 useful to identify the part of the program you're interested in.

 *

 On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com 
 wrote:
  Ok, I'm suddenly very curious by 

[android-developers] Re: Null pointer exception

2010-01-06 Thread Matt Kanninen
I do the management in onStop, for my cursor which supplies the data
needed by a ListView (which means the cursor has to be open whenever
the activity is displayed).

@Override
protected void onStop() {
super.onStop();
if(db!=null){
if(db.isOpen()){
db.close();
}
}
if(mCursor!=null){
if(!mCursor.isClosed()){
mCursor.close();
}
}
}

On Jan 6, 7:25 am, JasonMP hyperje...@gmail.com wrote:
 That was it!  I took out the startManagingCursor() and it worked
 fine.  My next question is what should I do to handle the life cycle
 of my cursor?  Should I close it outside the switch statement?

 On Jan 5, 5:41 pm, Vladimir vladimir.funti...@gmail.com wrote:

  What do you think about this:
  1. Cursor created in onContextItemSelected() is null (for some reason)
  2. Since its lifecycle is managed by the activity (startManagingCursor
  (c)), it tries to release it when the activity is stopped (when the
  new intent is launched)
  3. It doesn't expect managed cursor to be null and crashes (at
  android.app.Activity.performStop(Activity.java:3604))
  Does that make sense? I have little idea about how this cursor
  management works, but I would do the following:
  1. Try removing startManagingCursor() calls to see if these are
  related
  2. Double check if the cursor is null
  3. Take a look inside Android source and specifically Activity.java:
  3604
  Just a guess :)

  On Jan 5, 4:02 pm, JasonMP hyperje...@gmail.com wrote:

   Ok, I tried gino's idea with initializing my arrays differently.  I
   also changed there names so that they did not share a name with any
   other arrays in my app:  Did not work.

   I also tried calling to static variables instead of passing variables
   between classes with intents:  This also did not work.

   I can't determine which line of code causes the error.  The logcat
   does not give me a pointer to anything in my app at all.  I tried to
   narrow it down with breakpoints and logging and what I found is that
   it runs through all of my code without a hitch, and then once its done
   it throws the exception.

   And again the exception only happens when I call the intent from a
   contextMenu.

   On Jan 1, 2:56 am, Wiebbe wie...@gmail.com wrote:

Shouldnt you check if the bundle is null or not? Try to loop through
it when you get there from a onContextItemSelected event. I'm guessing
some value somewhere is null when it should be instantiated. Perhaps
the intent is started quicker or without the bundle somehow so you get
a nullpointer exception?

On 31 dec 2009, 15:57, JasonMP hyperje...@gmail.com wrote:

 yes, Select.class is another one of my files.  throughout my app there
 are a few different calls to it, all done the same way i.e. Intent i
 = new Intent(this, Select.class); startActivity(i);

 No where in Select.class do I make a call to start Select.class or
 Sheet.class.  When its done it calls finish();

 in the onCreate() of Select.class I grab the extras from the invoking
 class with this line of code:

 public class Select extends ListActivity{

         DBAdapter db = new DBAdapter(this);
         String slotName = null;

         @Override
         public void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);

                   db.open();

                   ListView list = getListView();

                   View v = View.inflate(this, R.layout.list_header, 
 null);
                   list.addHeaderView(v, null, false);

                   name = 
 this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
         }

 Could it be something in the .getIntent() method?  or
 the .getStringExtra()?

 On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
 wrote:

  Now that I understand your intent creation a little better, and I 
  see that
  the intent you are creating is unique from the class in which the 
  code
  exists, I am not quite sure how it could be an infinite loop in the
  (immediate) way I was thinking.

  Reading this code

  Intent i = new Intent(this, Select.class);

  I have to start thinking there's something wrong with this.  I 
  tried to look
  up the Select class on the android developers site, and couldn't 
  find it.
  Is that a class from another of your files?  I guess I would wonder 
  if the
  code being invoked there, is somehow causing this class to be 
  invoked, thus
  causing some kind of loop.  I would grep for any reference to your 
  Sheet
  class, from anywhere else in your code, and that would likely be 
  suspect.

  In general, 

[android-developers] Re: Null pointer exception

2010-01-06 Thread Martin
Hey, with eclipse, you can simply put a null-pointer-exception-
breakpoint, then debug your program and eclipse will stop there, where
the nullpointer creates this exception.
Greetings, Martin
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null pointer exception

2010-01-05 Thread JasonMP
Ok, I tried gino's idea with initializing my arrays differently.  I
also changed there names so that they did not share a name with any
other arrays in my app:  Did not work.

I also tried calling to static variables instead of passing variables
between classes with intents:  This also did not work.

I can't determine which line of code causes the error.  The logcat
does not give me a pointer to anything in my app at all.  I tried to
narrow it down with breakpoints and logging and what I found is that
it runs through all of my code without a hitch, and then once its done
it throws the exception.

And again the exception only happens when I call the intent from a
contextMenu.

On Jan 1, 2:56 am, Wiebbe wie...@gmail.com wrote:
 Shouldnt you check if the bundle is null or not? Try to loop through
 it when you get there from a onContextItemSelected event. I'm guessing
 some value somewhere is null when it should be instantiated. Perhaps
 the intent is started quicker or without the bundle somehow so you get
 a nullpointer exception?

 On 31 dec 2009, 15:57, JasonMP hyperje...@gmail.com wrote:



  yes, Select.class is another one of my files.  throughout my app there
  are a few different calls to it, all done the same way i.e. Intent i
  = new Intent(this, Select.class); startActivity(i);

  No where in Select.class do I make a call to start Select.class or
  Sheet.class.  When its done it calls finish();

  in the onCreate() of Select.class I grab the extras from the invoking
  class with this line of code:

  public class Select extends ListActivity{

          DBAdapter db = new DBAdapter(this);
          String slotName = null;

          @Override
          public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    db.open();

                    ListView list = getListView();

                    View v = View.inflate(this, R.layout.list_header, null);
                    list.addHeaderView(v, null, false);

                    name = 
  this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
          }

  Could it be something in the .getIntent() method?  or
  the .getStringExtra()?

  On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
  wrote:

   Now that I understand your intent creation a little better, and I see that
   the intent you are creating is unique from the class in which the code
   exists, I am not quite sure how it could be an infinite loop in the
   (immediate) way I was thinking.

   Reading this code

   Intent i = new Intent(this, Select.class);

   I have to start thinking there's something wrong with this.  I tried to 
   look
   up the Select class on the android developers site, and couldn't find 
   it.
   Is that a class from another of your files?  I guess I would wonder if the
   code being invoked there, is somehow causing this class to be invoked, 
   thus
   causing some kind of loop.  I would grep for any reference to your Sheet
   class, from anywhere else in your code, and that would likely be suspect.

   In general, the below is kind of a side topic, to maybe help you with
   generic debugging.

   All the Best, Steve.

   *Ok... the only thing I can think to really help you is to start taking
   advantage of logging.  In your import list, I see you don't include the
   logger code, so maybe you can give this a shot.

   1) in the import list

   import android.util.Log;

   2) and throughout your code

   Log.d( TAG, DebugText );

   where TAG is a string that is unique to you, and DebugText is something
   useful to identify the part of the program you're interested in.

   *

   On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
Ok, I'm suddenly very curious by your previous statement stephen about
the possibility of creating an infinite loop.  Upon a little more
investigation I'm now getting errors all over the place...same
errorjust at different points in the app where I try to
startActivity(intent);  As soon as the new activity receives focus is
crashes.

On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
 package com.mallet.dtool;

 import android.app.AlertDialog;
 import android.app.TabActivity;
 import android.app.AlertDialog.Builder;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.DialogInterface.OnClickListener;
 import android.content.res.Configuration;
 import android.database.Cursor;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.view.ContextMenu;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.AdapterView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import 

[android-developers] Re: Null pointer exception

2010-01-05 Thread Vladimir
What do you think about this:
1. Cursor created in onContextItemSelected() is null (for some reason)
2. Since its lifecycle is managed by the activity (startManagingCursor
(c)), it tries to release it when the activity is stopped (when the
new intent is launched)
3. It doesn't expect managed cursor to be null and crashes (at
android.app.Activity.performStop(Activity.java:3604))
Does that make sense? I have little idea about how this cursor
management works, but I would do the following:
1. Try removing startManagingCursor() calls to see if these are
related
2. Double check if the cursor is null
3. Take a look inside Android source and specifically Activity.java:
3604
Just a guess :)

On Jan 5, 4:02 pm, JasonMP hyperje...@gmail.com wrote:
 Ok, I tried gino's idea with initializing my arrays differently.  I
 also changed there names so that they did not share a name with any
 other arrays in my app:  Did not work.

 I also tried calling to static variables instead of passing variables
 between classes with intents:  This also did not work.

 I can't determine which line of code causes the error.  The logcat
 does not give me a pointer to anything in my app at all.  I tried to
 narrow it down with breakpoints and logging and what I found is that
 it runs through all of my code without a hitch, and then once its done
 it throws the exception.

 And again the exception only happens when I call the intent from a
 contextMenu.

 On Jan 1, 2:56 am, Wiebbe wie...@gmail.com wrote:



  Shouldnt you check if the bundle is null or not? Try to loop through
  it when you get there from a onContextItemSelected event. I'm guessing
  some value somewhere is null when it should be instantiated. Perhaps
  the intent is started quicker or without the bundle somehow so you get
  a nullpointer exception?

  On 31 dec 2009, 15:57, JasonMP hyperje...@gmail.com wrote:

   yes, Select.class is another one of my files.  throughout my app there
   are a few different calls to it, all done the same way i.e. Intent i
   = new Intent(this, Select.class); startActivity(i);

   No where in Select.class do I make a call to start Select.class or
   Sheet.class.  When its done it calls finish();

   in the onCreate() of Select.class I grab the extras from the invoking
   class with this line of code:

   public class Select extends ListActivity{

           DBAdapter db = new DBAdapter(this);
           String slotName = null;

           @Override
           public void onCreate(Bundle savedInstanceState) {
                     super.onCreate(savedInstanceState);

                     db.open();

                     ListView list = getListView();

                     View v = View.inflate(this, R.layout.list_header, null);
                     list.addHeaderView(v, null, false);

                     name = 
   this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
           }

   Could it be something in the .getIntent() method?  or
   the .getStringExtra()?

   On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
   wrote:

Now that I understand your intent creation a little better, and I see 
that
the intent you are creating is unique from the class in which the code
exists, I am not quite sure how it could be an infinite loop in the
(immediate) way I was thinking.

Reading this code

Intent i = new Intent(this, Select.class);

I have to start thinking there's something wrong with this.  I tried to 
look
up the Select class on the android developers site, and couldn't find 
it.
Is that a class from another of your files?  I guess I would wonder if 
the
code being invoked there, is somehow causing this class to be invoked, 
thus
causing some kind of loop.  I would grep for any reference to your Sheet
class, from anywhere else in your code, and that would likely be 
suspect.

In general, the below is kind of a side topic, to maybe help you with
generic debugging.

All the Best, Steve.

*Ok... the only thing I can think to really help you is to start taking
advantage of logging.  In your import list, I see you don't include the
logger code, so maybe you can give this a shot.

1) in the import list

import android.util.Log;

2) and throughout your code

Log.d( TAG, DebugText );

where TAG is a string that is unique to you, and DebugText is 
something
useful to identify the part of the program you're interested in.

*

On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
 Ok, I'm suddenly very curious by your previous statement stephen about
 the possibility of creating an infinite loop.  Upon a little more
 investigation I'm now getting errors all over the place...same
 errorjust at different points in the app where I try to
 startActivity(intent);  As soon as the new activity receives focus is
 crashes.

 On Dec 30, 1:58 pm, JasonMP 

[android-developers] Re: Null pointer exception

2009-12-31 Thread JasonMP
yes, Select.class is another one of my files.  throughout my app there
are a few different calls to it, all done the same way i.e. Intent i
= new Intent(this, Select.class); startActivity(i);


No where in Select.class do I make a call to start Select.class or
Sheet.class.  When its done it calls finish();


in the onCreate() of Select.class I grab the extras from the invoking
class with this line of code:

public class Select extends ListActivity{

DBAdapter db = new DBAdapter(this);
String slotName = null;

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  db.open();

  ListView list = getListView();

  View v = View.inflate(this, R.layout.list_header, null);
  list.addHeaderView(v, null, false);

  name = this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
}

Could it be something in the .getIntent() method?  or
the .getStringExtra()?




On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
wrote:
 Now that I understand your intent creation a little better, and I see that
 the intent you are creating is unique from the class in which the code
 exists, I am not quite sure how it could be an infinite loop in the
 (immediate) way I was thinking.

 Reading this code

 Intent i = new Intent(this, Select.class);

 I have to start thinking there's something wrong with this.  I tried to look
 up the Select class on the android developers site, and couldn't find it.
 Is that a class from another of your files?  I guess I would wonder if the
 code being invoked there, is somehow causing this class to be invoked, thus
 causing some kind of loop.  I would grep for any reference to your Sheet
 class, from anywhere else in your code, and that would likely be suspect.

 In general, the below is kind of a side topic, to maybe help you with
 generic debugging.

 All the Best, Steve.

 *Ok... the only thing I can think to really help you is to start taking
 advantage of logging.  In your import list, I see you don't include the
 logger code, so maybe you can give this a shot.

 1) in the import list

 import android.util.Log;

 2) and throughout your code

 Log.d( TAG, DebugText );

 where TAG is a string that is unique to you, and DebugText is something
 useful to identify the part of the program you're interested in.

 *



 On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
  Ok, I'm suddenly very curious by your previous statement stephen about
  the possibility of creating an infinite loop.  Upon a little more
  investigation I'm now getting errors all over the place...same
  errorjust at different points in the app where I try to
  startActivity(intent);  As soon as the new activity receives focus is
  crashes.

  On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
   package com.mallet.dtool;

   import android.app.AlertDialog;
   import android.app.TabActivity;
   import android.app.AlertDialog.Builder;
   import android.content.DialogInterface;
   import android.content.Intent;
   import android.content.DialogInterface.OnClickListener;
   import android.content.res.Configuration;
   import android.database.Cursor;
   import android.graphics.Color;
   import android.os.Bundle;
   import android.view.ContextMenu;
   import android.view.KeyEvent;
   import android.view.Menu;
   import android.view.MenuItem;
   import android.view.View;
   import android.view.ContextMenu.ContextMenuInfo;
   import android.widget.AdapterView;
   import android.widget.ImageView;
   import android.widget.LinearLayout;
   import android.widget.ListView;
   import android.widget.SimpleCursorAdapter;
   import android.widget.TabHost;
   import android.widget.TableLayout;
   import android.widget.TextView;
   import android.widget.Toast;
   import android.widget.AdapterView.AdapterContextMenuInfo;
   import android.widget.AdapterView.OnItemClickListener;
   import android.widget.TabHost.OnTabChangeListener;

   public class Sheet extends TabActivity{

           @Override public void onConfigurationChanged(Configuration
  newConfig)
   { super.onConfigurationChanged(newConfig); }
           DBAdapter db = new DBAdapter(this);
           static Long cRowId;

           //Variable declaration

           public static Integer tabState = 1;

           @Override
           public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.sheet);

           db.open();

           //capture Tab4 elements
           aList = (ListView) findViewById(R.id.alist);
           aList.setOnItemClickListener(new OnItemClickListener(){

                           @Override
                           public void onItemClick(AdapterView? arg0, View
  arg1, int arg2,
                                           long arg3) {

                                   Cursor c = 

[android-developers] Re: Null pointer exception

2009-12-31 Thread JasonMP
This is bizarre.

It works fine from the OnItemClick() of my OnItemClickListener
attached to my ListView.  Just not inside the onContextItemSelected.
*scratches head*

On Dec 31, 9:57 am, JasonMP hyperje...@gmail.com wrote:
 yes, Select.class is another one of my files.  throughout my app there
 are a few different calls to it, all done the same way i.e. Intent i
 = new Intent(this, Select.class); startActivity(i);

 No where in Select.class do I make a call to start Select.class or
 Sheet.class.  When its done it calls finish();

 in the onCreate() of Select.class I grab the extras from the invoking
 class with this line of code:

 public class Select extends ListActivity{

         DBAdapter db = new DBAdapter(this);
         String slotName = null;

         @Override
         public void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);

                   db.open();

                   ListView list = getListView();

                   View v = View.inflate(this, R.layout.list_header, null);
                   list.addHeaderView(v, null, false);

                   name = this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
         }

 Could it be something in the .getIntent() method?  or
 the .getStringExtra()?

 On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
 wrote:



  Now that I understand your intent creation a little better, and I see that
  the intent you are creating is unique from the class in which the code
  exists, I am not quite sure how it could be an infinite loop in the
  (immediate) way I was thinking.

  Reading this code

  Intent i = new Intent(this, Select.class);

  I have to start thinking there's something wrong with this.  I tried to look
  up the Select class on the android developers site, and couldn't find it.
  Is that a class from another of your files?  I guess I would wonder if the
  code being invoked there, is somehow causing this class to be invoked, thus
  causing some kind of loop.  I would grep for any reference to your Sheet
  class, from anywhere else in your code, and that would likely be suspect.

  In general, the below is kind of a side topic, to maybe help you with
  generic debugging.

  All the Best, Steve.

  *Ok... the only thing I can think to really help you is to start taking
  advantage of logging.  In your import list, I see you don't include the
  logger code, so maybe you can give this a shot.

  1) in the import list

  import android.util.Log;

  2) and throughout your code

  Log.d( TAG, DebugText );

  where TAG is a string that is unique to you, and DebugText is something
  useful to identify the part of the program you're interested in.

  *

  On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
   Ok, I'm suddenly very curious by your previous statement stephen about
   the possibility of creating an infinite loop.  Upon a little more
   investigation I'm now getting errors all over the place...same
   errorjust at different points in the app where I try to
   startActivity(intent);  As soon as the new activity receives focus is
   crashes.

   On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
package com.mallet.dtool;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TabHost.OnTabChangeListener;

public class Sheet extends TabActivity{

        @Override public void onConfigurationChanged(Configuration
   newConfig)
{ super.onConfigurationChanged(newConfig); }
        DBAdapter db = new DBAdapter(this);
        static Long cRowId;

        //Variable declaration

        public static Integer tabState = 1;

        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sheet);

        db.open();

        //capture Tab4 elements
        aList = (ListView) 

[android-developers] Re: Null pointer exception

2009-12-31 Thread g...@devicedriven
Hi Jason

I too was irked with the same exception which got called in some of my
applications and i couldn't find the source for the exception.However
i think i found the reason for it..Here is what i found:

1This exception was called in all the programs in which i used arrays
2Just try this://You have used two arrays in your program from[], and
to[]

Either try a static initialization like this--String from[]=new String
[YOUR_ARRAY_SIZE]
   OR
Another option is to initialize them to any value(Even initialization
with null is fine)

This seemed to work for all my programs..hope it does for you too!

PS:It would really help if you can tell which line of ur code throws
the exception

On Dec 31 2009, 9:33 pm, JasonMP hyperje...@gmail.com wrote:
 This is bizarre.

 It works fine from the OnItemClick() of my OnItemClickListener
 attached to my ListView.  Just not inside the onContextItemSelected.
 *scratches head*

 On Dec 31, 9:57 am, JasonMP hyperje...@gmail.com wrote:

  yes, Select.class is another one of my files.  throughout my app there
  are a few different calls to it, all done the same way i.e. Intent i
  = new Intent(this, Select.class); startActivity(i);

  No where in Select.class do I make a call to start Select.class or
  Sheet.class.  When its done it calls finish();

  in the onCreate() of Select.class I grab the extras from the invoking
  class with this line of code:

  public class Select extends ListActivity{

          DBAdapter db = new DBAdapter(this);
          String slotName = null;

          @Override
          public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    db.open();

                    ListView list = getListView();

                    View v = View.inflate(this, R.layout.list_header, null);
                    list.addHeaderView(v, null, false);

                    name = 
  this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
          }

  Could it be something in the .getIntent() method?  or
  the .getStringExtra()?

  On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
  wrote:

   Now that I understand your intent creation a little better, and I see that
   the intent you are creating is unique from the class in which the code
   exists, I am not quite sure how it could be an infinite loop in the
   (immediate) way I was thinking.

   Reading this code

   Intent i = new Intent(this, Select.class);

   I have to start thinking there's something wrong with this.  I tried to 
   look
   up the Select class on the android developers site, and couldn't find 
   it.
   Is that a class from another of your files?  I guess I would wonder if the
   code being invoked there, is somehow causing this class to be invoked, 
   thus
   causing some kind of loop.  I would grep for any reference to your Sheet
   class, from anywhere else in your code, and that would likely be suspect.

   In general, the below is kind of a side topic, to maybe help you with
   generic debugging.

   All the Best, Steve.

   *Ok... the only thing I can think to really help you is to start taking
   advantage of logging.  In your import list, I see you don't include the
   logger code, so maybe you can give this a shot.

   1) in the import list

   import android.util.Log;

   2) and throughout your code

   Log.d( TAG, DebugText );

   where TAG is a string that is unique to you, and DebugText is something
   useful to identify the part of the program you're interested in.

   *

   On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
Ok, I'm suddenly very curious by your previous statement stephen about
the possibility of creating an infinite loop.  Upon a little more
investigation I'm now getting errors all over the place...same
errorjust at different points in the app where I try to
startActivity(intent);  As soon as the new activity receives focus is
crashes.

On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
 package com.mallet.dtool;

 import android.app.AlertDialog;
 import android.app.TabActivity;
 import android.app.AlertDialog.Builder;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.DialogInterface.OnClickListener;
 import android.content.res.Configuration;
 import android.database.Cursor;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.view.ContextMenu;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.AdapterView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
 import android.widget.TabHost;
 import android.widget.TableLayout;
 

[android-developers] Re: Null pointer exception

2009-12-31 Thread Wiebbe
Shouldnt you check if the bundle is null or not? Try to loop through
it when you get there from a onContextItemSelected event. I'm guessing
some value somewhere is null when it should be instantiated. Perhaps
the intent is started quicker or without the bundle somehow so you get
a nullpointer exception?

On 31 dec 2009, 15:57, JasonMP hyperje...@gmail.com wrote:
 yes, Select.class is another one of my files.  throughout my app there
 are a few different calls to it, all done the same way i.e. Intent i
 = new Intent(this, Select.class); startActivity(i);

 No where in Select.class do I make a call to start Select.class or
 Sheet.class.  When its done it calls finish();

 in the onCreate() of Select.class I grab the extras from the invoking
 class with this line of code:

 public class Select extends ListActivity{

         DBAdapter db = new DBAdapter(this);
         String slotName = null;

         @Override
         public void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);

                   db.open();

                   ListView list = getListView();

                   View v = View.inflate(this, R.layout.list_header, null);
                   list.addHeaderView(v, null, false);

                   name = this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
         }

 Could it be something in the .getIntent() method?  or
 the .getStringExtra()?

 On Dec 30, 7:19 pm, Stephen @ gmail.com sdickey2...@gmail.com
 wrote:



  Now that I understand your intent creation a little better, and I see that
  the intent you are creating is unique from the class in which the code
  exists, I am not quite sure how it could be an infinite loop in the
  (immediate) way I was thinking.

  Reading this code

  Intent i = new Intent(this, Select.class);

  I have to start thinking there's something wrong with this.  I tried to look
  up the Select class on the android developers site, and couldn't find it.
  Is that a class from another of your files?  I guess I would wonder if the
  code being invoked there, is somehow causing this class to be invoked, thus
  causing some kind of loop.  I would grep for any reference to your Sheet
  class, from anywhere else in your code, and that would likely be suspect.

  In general, the below is kind of a side topic, to maybe help you with
  generic debugging.

  All the Best, Steve.

  *Ok... the only thing I can think to really help you is to start taking
  advantage of logging.  In your import list, I see you don't include the
  logger code, so maybe you can give this a shot.

  1) in the import list

  import android.util.Log;

  2) and throughout your code

  Log.d( TAG, DebugText );

  where TAG is a string that is unique to you, and DebugText is something
  useful to identify the part of the program you're interested in.

  *

  On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:
   Ok, I'm suddenly very curious by your previous statement stephen about
   the possibility of creating an infinite loop.  Upon a little more
   investigation I'm now getting errors all over the place...same
   errorjust at different points in the app where I try to
   startActivity(intent);  As soon as the new activity receives focus is
   crashes.

   On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
package com.mallet.dtool;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TabHost.OnTabChangeListener;

public class Sheet extends TabActivity{

        @Override public void onConfigurationChanged(Configuration
   newConfig)
{ super.onConfigurationChanged(newConfig); }
        DBAdapter db = new DBAdapter(this);
        static Long cRowId;

        //Variable declaration

        public static Integer tabState = 1;

        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
  

[android-developers] Re: Null pointer exception

2009-12-30 Thread Matt
I would just step through it with the debugger (assuming you are using
Eclipse)


On Dec 30, 8:39 am, JasonMP hyperje...@gmail.com wrote:
 Anyone know what would cause this error?

 12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
 thread main exiting due to uncaught exception

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):
 java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
 com.mallet.dtool.Sheet}: java.lang.NullPointerException

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread.performStopActivityInner
 (ActivityThread.java:3124)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread.handleStopActivity(ActivityThread.java:
 3167)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread.access$2400(ActivityThread.java:116)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.os.Handler.dispatchMessage(Handler.java:99)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.os.Looper.loop(Looper.java:123)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread.main(ActivityThread.java:4203)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 java.lang.reflect.Method.invokeNative(Native Method)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 java.lang.reflect.Method.invoke(Method.java:521)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
 (ZygoteInit.java:791)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 dalvik.system.NativeStart.main(Native Method)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
 java.lang.NullPointerException

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.Activity.performStop(Activity.java:3604)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
 android.app.ActivityThread.performStopActivityInner
 (ActivityThread.java:3121)

 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     ... 11 more

 This is the code it runs when I get the error (this is a context menu
 option from a listview)

 Cursor c = db.getInfo(name);
 c.moveToPosition(info.position - 1);
 Intent i = new Intent(this, Select.class);
 i.putExtra(name, c.getString(c.getColumnIndexOrThrow
 (DBAdapter.KEY_NAME)));

 startActivity(i);

 this launches another activity that when opened from other areas of my
 app work fine.  I checked to see if it had anything to do with the
 extras and it didn't seem to(i removed them entirely).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Yes I'm using eclipse.  I use the debugger and when I hit that point
in my app i get the above error in my logcat window.  Is there another
way to debug in eclipse?

On Dec 30, 1:01 pm, Matt hansen.matt...@gmail.com wrote:
 I would just step through it with the debugger (assuming you are using
 Eclipse)

 On Dec 30, 8:39 am, JasonMP hyperje...@gmail.com wrote:



  Anyone know what would cause this error?

  12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
  thread main exiting due to uncaught exception

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):
  java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
  com.mallet.dtool.Sheet}: java.lang.NullPointerException

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread.performStopActivityInner
  (ActivityThread.java:3124)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread.handleStopActivity(ActivityThread.java:
  3167)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread.access$2400(ActivityThread.java:116)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.os.Handler.dispatchMessage(Handler.java:99)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.os.Looper.loop(Looper.java:123)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread.main(ActivityThread.java:4203)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  java.lang.reflect.Method.invokeNative(Native Method)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  java.lang.reflect.Method.invoke(Method.java:521)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
  (ZygoteInit.java:791)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  dalvik.system.NativeStart.main(Native Method)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
  java.lang.NullPointerException

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.Activity.performStop(Activity.java:3604)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
  android.app.ActivityThread.performStopActivityInner
  (ActivityThread.java:3121)

  12-30 10:26:50.928: ERROR/AndroidRuntime(921):     ... 11 more

  This is the code it runs when I get the error (this is a context menu
  option from a listview)

  Cursor c = db.getInfo(name);
  c.moveToPosition(info.position - 1);
  Intent i = new Intent(this, Select.class);
  i.putExtra(name, c.getString(c.getColumnIndexOrThrow
  (DBAdapter.KEY_NAME)));

  startActivity(i);

  this launches another activity that when opened from other areas of my
  app work fine.  I checked to see if it had anything to do with the
  extras and it didn't seem to(i removed them entirely).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Null pointer exception

2009-12-30 Thread Stephen @ gmail.com
Sorry if this sounds silly: you might want to set a breakpoint on line:

startActivity(i);

when you hit that point, examine i carefully.  From your log, I wonder if
the act of starting the activity invokes your current code, inducing an
infinite loop.  Also, if it were my code, I would want to ensure I catch all
uncaught exceptions.  Around your code that you feel is failing, I would
catch the general Exception as well as the AndroidRuntimeException (cannot
remember if I've spelled that perfectly right), and print out the stack
frame from the exception that was caught.  that might yield additional info.

Finally, further assistance from the forum, you may want to include more of
your code.  You probably have something special in there you don't want to
share... just make what you post generic enough so we can see the construct
of your whole activity.

all the best, steve.

On Wed, Dec 30, 2009 at 10:10 AM, JasonMP hyperje...@gmail.com wrote:

 Yes I'm using eclipse.  I use the debugger and when I hit that point
 in my app i get the above error in my logcat window.  Is there another
 way to debug in eclipse?

 On Dec 30, 1:01 pm, Matt hansen.matt...@gmail.com wrote:
  I would just step through it with the debugger (assuming you are using
  Eclipse)
 
  On Dec 30, 8:39 am, JasonMP hyperje...@gmail.com wrote:
 
 
 
   Anyone know what would cause this error?
 
   12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
   thread main exiting due to uncaught exception
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921):
   java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
   com.mallet.dtool.Sheet}: java.lang.NullPointerException
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread.performStopActivityInner
   (ActivityThread.java:3124)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread.handleStopActivity(ActivityThread.java:
   3167)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread.access$2400(ActivityThread.java:116)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.os.Handler.dispatchMessage(Handler.java:99)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.os.Looper.loop(Looper.java:123)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread.main(ActivityThread.java:4203)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   java.lang.reflect.Method.invokeNative(Native Method)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   java.lang.reflect.Method.invoke(Method.java:521)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
   (ZygoteInit.java:791)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   dalvik.system.NativeStart.main(Native Method)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
   java.lang.NullPointerException
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.Activity.performStop(Activity.java:3604)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
   android.app.ActivityThread.performStopActivityInner
   (ActivityThread.java:3121)
 
   12-30 10:26:50.928: ERROR/AndroidRuntime(921): ... 11 more
 
   This is the code it runs when I get the error (this is a context menu
   option from a listview)
 
   Cursor c = db.getInfo(name);
   c.moveToPosition(info.position - 1);
   Intent i = new Intent(this, Select.class);
   i.putExtra(name, c.getString(c.getColumnIndexOrThrow
   (DBAdapter.KEY_NAME)));
 
   startActivity(i);
 
   this launches another activity that when opened from other areas of my
   app work fine.  I checked to see if it had anything to do with the
   extras and it didn't seem to(i removed them entirely).

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Hmm, Ok, I've placed the breakpoint in and everything appears to be
fine, but it still doesn't work.  This code is essentially a copy/
paste from another area of my app.  In that instance its being called
from a ListView contextmenu as well and works fine.  What do you mean
exactly by catching ALL the exceptions?  Is that something I need to
add into the code?

On Dec 30, 1:21 pm, Stephen @ gmail.com sdickey2...@gmail.com
wrote:
 Sorry if this sounds silly: you might want to set a breakpoint on line:

 startActivity(i);

 when you hit that point, examine i carefully.  From your log, I wonder if
 the act of starting the activity invokes your current code, inducing an
 infinite loop.  Also, if it were my code, I would want to ensure I catch all
 uncaught exceptions.  Around your code that you feel is failing, I would
 catch the general Exception as well as the AndroidRuntimeException (cannot
 remember if I've spelled that perfectly right), and print out the stack
 frame from the exception that was caught.  that might yield additional info.

 Finally, further assistance from the forum, you may want to include more of
 your code.  You probably have something special in there you don't want to
 share... just make what you post generic enough so we can see the construct
 of your whole activity.

 all the best, steve.



 On Wed, Dec 30, 2009 at 10:10 AM, JasonMP hyperje...@gmail.com wrote:
  Yes I'm using eclipse.  I use the debugger and when I hit that point
  in my app i get the above error in my logcat window.  Is there another
  way to debug in eclipse?

  On Dec 30, 1:01 pm, Matt hansen.matt...@gmail.com wrote:
   I would just step through it with the debugger (assuming you are using
   Eclipse)

   On Dec 30, 8:39 am, JasonMP hyperje...@gmail.com wrote:

Anyone know what would cause this error?

12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
thread main exiting due to uncaught exception

12-30 10:26:50.928: ERROR/AndroidRuntime(921):
java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
com.mallet.dtool.Sheet}: java.lang.NullPointerException

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:3124)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread.handleStopActivity(ActivityThread.java:
3167)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread.access$2400(ActivityThread.java:116)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.os.Handler.dispatchMessage(Handler.java:99)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.os.Looper.loop(Looper.java:123)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread.main(ActivityThread.java:4203)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
java.lang.reflect.Method.invokeNative(Native Method)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
java.lang.reflect.Method.invoke(Method.java:521)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
dalvik.system.NativeStart.main(Native Method)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
java.lang.NullPointerException

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.Activity.performStop(Activity.java:3604)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:3121)

12-30 10:26:50.928: ERROR/AndroidRuntime(921):     ... 11 more

This is the code it runs when I get the error (this is a context menu
option from a listview)

Cursor c = db.getInfo(name);
c.moveToPosition(info.position - 1);
Intent i = new Intent(this, Select.class);
i.putExtra(name, c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));

startActivity(i);

this launches another activity that when opened from other areas of my
app work fine.  I checked to see if it had anything to do with the
extras and it didn't seem to(i removed them entirely).

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
package com.mallet.dtool;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TabHost.OnTabChangeListener;

public class Sheet extends TabActivity{


@Override public void onConfigurationChanged(Configuration newConfig)
{ super.onConfigurationChanged(newConfig); }
DBAdapter db = new DBAdapter(this);
static Long cRowId;


//Variable declaration

public static Integer tabState = 1;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sheet);

db.open();


//capture Tab4 elements
aList = (ListView) findViewById(R.id.alist);
aList.setOnItemClickListener(new OnItemClickListener(){


@Override
public void onItemClick(AdapterView? arg0, View arg1, 
int arg2,
long arg3) {

Cursor c = db.getAll(Sheet.charName);


c.moveToPosition(arg2 - 1);

Builder builder2 = new AlertDialog.Builder(Sheet.this);
builder2.setTitle(c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));
builder2.setIcon(R.drawable.equipment);
builder2.setMessage(c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_DESC)));
builder2.setPositiveButton(Ok, null);
builder2.show();


}

});
registerForContextMenu(aList);


}
@Override
public void onResume()
{
 super.onResume();

 fillAList();
}
@Override
public void onDestroy(){
super.onDestroy();
db.close();
}




@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {

if(v == aList){
menu.add(0, 7, 0, option 1);
}
}

@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo)
item.getMenuInfo();
Cursor c = null;
startManagingCursor(c);
Long id;
Integer idInt;

switch(item.getItemId()) {

case 7:
c = db.getInfo(name);
c.moveToPosition(info.position - 1);
Intent i = new Intent(this, Select.class);
i.putExtra(DBAdapter.KEY_NAME, 
c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));
startActivity(i);

return true;
}

return super.onContextItemSelected(item);
}

public void fillArmorList(){


Cursor c = db.getAll(Sheet.charName);
startManagingCursor(c);

String[] from = new String[]{//DB columns};


int[] to = new int[]{//Layout Elements};


SimpleCursorAdapter items = new SimpleCursorAdapter(this,
R.layout.item_row, c, from, to);
aList.setAdapter(items);
}



}

On Dec 30, 1:41 pm, JasonMP hyperje...@gmail.com wrote:
 Hmm, Ok, I've placed the breakpoint in and everything appears to be
 fine, but it still doesn't work.  This code is essentially a copy/
 paste from another area of my app.  In that instance its being called
 from a ListView contextmenu as well and works fine.  What do you mean
 exactly by catching ALL the exceptions?  Is that something I need to
 add into the code?

 On Dec 30, 1:21 pm, Stephen @ gmail.com sdickey2...@gmail.com
 wrote:



  Sorry if this sounds silly: you might want to set a breakpoint on line:

  startActivity(i);

  when you hit that point, examine i carefully.  From your log, I wonder if
  the act of starting the activity invokes your current code, inducing an
  infinite loop.  Also, if it were my code, I would want to ensure I catch all
  uncaught exceptions.  Around 

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Ok, I'm suddenly very curious by your previous statement stephen about
the possibility of creating an infinite loop.  Upon a little more
investigation I'm now getting errors all over the place...same
errorjust at different points in the app where I try to
startActivity(intent);  As soon as the new activity receives focus is
crashes.

On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
 package com.mallet.dtool;

 import android.app.AlertDialog;
 import android.app.TabActivity;
 import android.app.AlertDialog.Builder;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.DialogInterface.OnClickListener;
 import android.content.res.Configuration;
 import android.database.Cursor;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.view.ContextMenu;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.AdapterView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
 import android.widget.TabHost;
 import android.widget.TableLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.TabHost.OnTabChangeListener;

 public class Sheet extends TabActivity{

         @Override public void onConfigurationChanged(Configuration newConfig)
 { super.onConfigurationChanged(newConfig); }
         DBAdapter db = new DBAdapter(this);
         static Long cRowId;

         //Variable declaration

         public static Integer tabState = 1;

         @Override
         public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.sheet);

         db.open();

         //capture Tab4 elements
         aList = (ListView) findViewById(R.id.alist);
         aList.setOnItemClickListener(new OnItemClickListener(){

                         @Override
                         public void onItemClick(AdapterView? arg0, View 
 arg1, int arg2,
                                         long arg3) {

                                 Cursor c = db.getAll(Sheet.charName);

                         c.moveToPosition(arg2 - 1);

                         Builder builder2 = new 
 AlertDialog.Builder(Sheet.this);
                     builder2.setTitle(c.getString(c.getColumnIndexOrThrow
 (DBAdapter.KEY_NAME)));
                     builder2.setIcon(R.drawable.equipment);
                     builder2.setMessage(c.getString(c.getColumnIndexOrThrow
 (DBAdapter.KEY_DESC)));
                     builder2.setPositiveButton(Ok, null);
                     builder2.show();

                         }

         });
         registerForContextMenu(aList);

         }
         @Override
         public void onResume()
         {
                  super.onResume();

                  fillAList();
         }
         @Override
         public void onDestroy(){
                 super.onDestroy();
                 db.close();
         }

     @Override
         public void onCreateContextMenu(ContextMenu menu, View v,
                         ContextMenuInfo menuInfo) {

         if(v == aList){
                 menu.add(0, 7, 0, option 1);
         }
         }

     @Override
         public boolean onContextItemSelected(MenuItem item) {
         AdapterContextMenuInfo info = (AdapterContextMenuInfo)
 item.getMenuInfo();
         Cursor c = null;
         startManagingCursor(c);
         Long id;
         Integer idInt;

         switch(item.getItemId()) {

         case 7:
                 c = db.getInfo(name);
                 c.moveToPosition(info.position - 1);
                 Intent i = new Intent(this, Select.class);
                 i.putExtra(DBAdapter.KEY_NAME, 
 c.getString(c.getColumnIndexOrThrow
 (DBAdapter.KEY_NAME)));
                 startActivity(i);

                 return true;
         }

                 return super.onContextItemSelected(item);
         }

     public void fillArmorList(){

                 Cursor c = db.getAll(Sheet.charName);
                 startManagingCursor(c);

                 String[] from = new String[]{//DB columns};

                 int[] to = new int[]{//Layout Elements};

                 SimpleCursorAdapter items = new SimpleCursorAdapter(this,
 R.layout.item_row, c, from, to);
                 aList.setAdapter(items);
         }

 }

 On Dec 30, 1:41 pm, JasonMP hyperje...@gmail.com wrote:



  Hmm, Ok, I've placed the breakpoint in and everything appears to be
  fine, but it still doesn't work.  This code is essentially a copy/
  paste from another area of my app.  In that instance its being called
  from a ListView contextmenu as well and works fine.  What do you mean
  exactly by 

Re: [android-developers] Re: Null pointer exception

2009-12-30 Thread Stephen @ gmail.com
Now that I understand your intent creation a little better, and I see that
the intent you are creating is unique from the class in which the code
exists, I am not quite sure how it could be an infinite loop in the
(immediate) way I was thinking.

Reading this code

Intent i = new Intent(this, Select.class);

I have to start thinking there's something wrong with this.  I tried to look
up the Select class on the android developers site, and couldn't find it.
Is that a class from another of your files?  I guess I would wonder if the
code being invoked there, is somehow causing this class to be invoked, thus
causing some kind of loop.  I would grep for any reference to your Sheet
class, from anywhere else in your code, and that would likely be suspect.

In general, the below is kind of a side topic, to maybe help you with
generic debugging.

All the Best, Steve.

*Ok... the only thing I can think to really help you is to start taking
advantage of logging.  In your import list, I see you don't include the
logger code, so maybe you can give this a shot.

1) in the import list

import android.util.Log;

2) and throughout your code

Log.d( TAG, DebugText );

where TAG is a string that is unique to you, and DebugText is something
useful to identify the part of the program you're interested in.

*

On Wed, Dec 30, 2009 at 11:32 AM, JasonMP hyperje...@gmail.com wrote:

 Ok, I'm suddenly very curious by your previous statement stephen about
 the possibility of creating an infinite loop.  Upon a little more
 investigation I'm now getting errors all over the place...same
 errorjust at different points in the app where I try to
 startActivity(intent);  As soon as the new activity receives focus is
 crashes.

 On Dec 30, 1:58 pm, JasonMP hyperje...@gmail.com wrote:
  package com.mallet.dtool;
 
  import android.app.AlertDialog;
  import android.app.TabActivity;
  import android.app.AlertDialog.Builder;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.DialogInterface.OnClickListener;
  import android.content.res.Configuration;
  import android.database.Cursor;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.ContextMenu;
  import android.view.KeyEvent;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ContextMenu.ContextMenuInfo;
  import android.widget.AdapterView;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
  import android.widget.TabHost;
  import android.widget.TableLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.widget.AdapterView.AdapterContextMenuInfo;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.TabHost.OnTabChangeListener;
 
  public class Sheet extends TabActivity{
 
  @Override public void onConfigurationChanged(Configuration
 newConfig)
  { super.onConfigurationChanged(newConfig); }
  DBAdapter db = new DBAdapter(this);
  static Long cRowId;
 
  //Variable declaration
 
  public static Integer tabState = 1;
 
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.sheet);
 
  db.open();
 
  //capture Tab4 elements
  aList = (ListView) findViewById(R.id.alist);
  aList.setOnItemClickListener(new OnItemClickListener(){
 
  @Override
  public void onItemClick(AdapterView? arg0, View
 arg1, int arg2,
  long arg3) {
 
  Cursor c = db.getAll(Sheet.charName);
 
  c.moveToPosition(arg2 - 1);
 
  Builder builder2 = new
 AlertDialog.Builder(Sheet.this);
  builder2.setTitle(c.getString(c.getColumnIndexOrThrow
  (DBAdapter.KEY_NAME)));
  builder2.setIcon(R.drawable.equipment);
 
 builder2.setMessage(c.getString(c.getColumnIndexOrThrow
  (DBAdapter.KEY_DESC)));
  builder2.setPositiveButton(Ok, null);
  builder2.show();
 
  }
 
  });
  registerForContextMenu(aList);
 
  }
  @Override
  public void onResume()
  {
   super.onResume();
 
   fillAList();
  }
  @Override
  public void onDestroy(){
  super.onDestroy();
  db.close();
  }
 
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v,
  ContextMenuInfo menuInfo) {
 
  if(v == aList){
  menu.add(0, 7, 0, option 1);
  }
  }
 
  @Override
  public boolean 

[android-developers] Re: Null pointer exception while receiving at Broadcast receiver

2009-09-06 Thread Randy McEoin

It would be best to check for null before attempting to use.  Perhaps
whatever is issuing the broadcast is not adding the string extra.

String msg_receive = intent.getStringExtra(message1);
if (msg_receive != null)  {
   AssetTest.hh_text.append(\n\n+msg_receive);
}

Randy

On Sep 3, 10:49 pm, Asif k asifk1...@gmail.com wrote:
 Hi all,

   I am receiving Text messages from another application sent through
 broadcast intent. I am displaying these messages to my application's
 GUI.

   In my application I had defined broadcast receiver in my
 manifest.xml

 --
 receiver android:name=.HHBroadcastReceiver
                         intent-filter
                         action android:name=android.demo.test/
                         /intent-filter
                 /receiver
 -
 and also define the logic in the Broadcast receiver class

 ---
 public class HHBroadcastReceiver extends BroadcastReceiver {
 @Override
 public void onReceive(Context context, Intent intent) {
 //TODO: React to the Intent received.
         String msg_receive = intent.getStringExtra(message1);
         AssetTest.hh_text.append(\n\n+msg_receive);}
 }

 -

 but I am getting following error,

 09-04 10:49:04.275: ERROR/AndroidRuntime(912):
 java.lang.RuntimeException: Unable to start receiver
 android.hh.HHBroadcastReceiver: java.lang.NullPointerException
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.app.ActivityThread.handleReceiver(ActivityThread.java:2417)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.app.ActivityThread.access$2700(ActivityThread.java:112)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1741)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.os.Handler.dispatchMessage(Handler.java:99)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.os.Looper.loop(Looper.java:123)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.app.ActivityThread.main(ActivityThread.java:3948)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 java.lang.reflect.Method.invokeNative(Native Method)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 java.lang.reflect.Method.invoke(Method.java:521)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
 (ZygoteInit.java:782)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 dalvik.system.NativeStart.main(Native Method)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912): Caused by:
 java.lang.NullPointerException
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.hh.HHBroadcastReceiver.onReceive(HHBroadcastReceiver.java:12)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     at
 android.app.ActivityThread.handleReceiver(ActivityThread.java:2408)
 09-04 10:49:04.275: ERROR/AndroidRuntime(912):     ... 10 more

 Please help.

 Thanks,
 Asif
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception

2009-08-30 Thread Dexter's Brain

Without looking at your code, it si practically impossible to suggest
something to you...

Dexter.

On Aug 31, 9:51 am, Sasi Kumar sasikumar.it1...@gmail.com wrote:
 when i'm trying to call another class method.
 It is showing null pointer exception.

 Plz give some suggestion to get back from this
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception

2009-08-30 Thread Roman ( T-Mobile USA)

My first guess is that your variable is not instantiated that's why
you cannot call the method.

 but let's look at your code first 

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Aug 30, 9:51 pm, Sasi Kumar sasikumar.it1...@gmail.com wrote:
 when i'm trying to call another class method.
 It is showing null pointer exception.

 Plz give some suggestion to get back from this
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null pointer exception while using setOnClickListener

2009-04-21 Thread e-satis

I solved the problem building a custom view list adapter. I post the
code here with some comments so it can help any body else :


import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;




public class ItemListAdapter extends SimpleCursorAdapter
{
private Context context;
private int layout_id;


// initialize the on click listeners. It's static so it's share with
all the buttons to avoid object creation

// navigation with the arrow button
private static final OnClickListener arrow_button_on_click_listener =
new OnClickListener() {

public void onClick(View v) {

// on click, get the id of the item, make it the current node
// then refresh the view so we see its children

InContext list = (InContext) v.getContext();
list.setCurrentNode(v.getId());
list.refreshView();

}
};

// validation with the check box button

// initialize the listener. It's static so it's share with all the
buttons to avoid object creation
private static final OnClickListener check_box_on_click_listener =
new OnClickListener() {

public void onClick(View v) {

// on click, get the id of the item, make it the current node
// then refresh the view so we see its children

InContext list = (InContext) v.getContext();

// this state is the contrary of the previous one
int checked = 1;
if (((CheckBox) v).isChecked())
checked = 0;

list.toggleItem(v.getId(), checked);
}
};


public ItemListAdapter(Context context, int layout_id, Cursor
c,String[] from, int[] to)
{
super(context, layout_id, c, from, to);
this.context = context;
this.layout_id = layout_id;
}


/**
 * Custom view translates columns into checkbox, title and arrow
 *
 * @see android.widget.CursorAdapter#getView(int,
android.view.View, android.view.ViewGroup)
 */
public View getView(int position, View convertView, ViewGroup
parent)
{

// no need to manage the cursor, thanks to the
simplecursoradapter, it will be on the right position
Cursor cursor = getCursor();
cursor.moveToPosition(position);

// get the id of the item, so we can store it in each view
int index = cursor.getColumnIndex(ItemDbHelper.KEY_ID);
int _id = cursor.getInt(index);

/* inflate the list row view from the XML so we can
instanciate it's child with findViewById
 if we don't do that, we'll get null from findViewById and so
a null pointer exception */

// first we get the instance of the inflater that is pre
configured for this phone
LayoutInflater inflater = LayoutInflater.from(this.context);
// then, we inflate the view with it
View v = inflater.inflate(this.layout_id,
parent,
false); // we 
don't want the layout to be bound to any
root for the moment, setAdapter() will do that



// set the value of the item title of each row
TextView item_title = (TextView) v.findViewById
(R.id.item_title);
index = cursor.getColumnIndex(ItemDbHelper.KEY_TITLE);
item_title.setText(cursor.getString(index));

// set the status of the checkbox of each row
CheckBox  item_checkbox = (CheckBox) v.findViewById
(R.id.row_checkbox);
item_checkbox.setId(_id);
index = cursor.getColumnIndex(ItemDbHelper.KEY_CHECKED);
if (cursor.getInt(index) == 0)
item_checkbox.setChecked(false);
else
item_checkbox.setChecked(true);

// set the check box click listener to perform db update on
clic
item_checkbox.setOnClickListener(check_box_on_click_listener);

// set the image of the image button according to the number
of childrdb en
ImageButton  arrow = (ImageButton) v.findViewById
(R.id.arrow_right);
arrow.setId(_id);
index = cursor.getColumnIndex
(ItemDbHelper.KEY_CHILDREN_COUNT);
if (cursor.getInt(index) == 0)
arrow.setImageResource(R.drawable.arrow);
else
arrow.setImageResource(R.drawable.double_arrow);

// set the arrow button click listener to navigate in depth in
the node list
arrow.setOnClickListener(arrow_button_on_click_listener);



return v;
}
}


On Apr 7, 8:56 pm, e-satis info.ksam...@googlemail.com wrote:
 My row 

[android-developers] Re: Null pointer exception while using setOnClickListener

2009-04-07 Thread e-satis

Update : setContentView first and before all, checked :-)

On 7 avr, 20:09, e-satis info.ksam...@googlemail.com wrote:
 Update : Reading other posts, I tried to trash the R.java file but it
 was not the cause.

 On 7 avr, 19:48, e-satis info.ksam...@googlemail.com wrote:

  Hi,

  My java code look like this :

          // right_arrow button
          ImageButton arrow_button = (ImageButton)findViewById
  (R.id.arrow);
          arrow_button.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                   ((View)v.getParent().getParent()).setSelected(true);
              }
          });

  And the corresponding XML look like :

  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
  android
      android:id=@+id/row_layout 

      LinearLayout android:id=@+id/row_checkbox_container

          CheckBox android:id=@+id/row_checkbox /

      /LinearLayout

     LinearLayout android:id=@+id/item_title_container

          TextView android:id=@+id/item_title/

      /LinearLayout

      LinearLayout android:id=@+id/right_arrow_container 

       ImageButton android:id=@+id/arrow
                      android:layout_width=18px
                      android:layout_height=fill_parent
                      android:layout_gravity=bottom
                      android:layout_weight=1
                      android:src=@drawable/arrow
                      android:background=#/

      /LinearLayout

  /LinearLayout

  I got anullpointerexceptionright after running the app in the
  emulator from eclipse on Ubuntu 8.10 :

  E/AndroidRuntime( 1426): java.lang.RuntimeException: Unable to start
  activity ComponentInfo{com.getincontext/com.getincontext.InContext}:
  java.lang.NullPointerException
  E/AndroidRuntime( 1426):        at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
  2141)
  E/AndroidRuntime( 1426):        at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
  2157)
  E/AndroidRuntime( 1426):        at android.app.ActivityThread.access$1800
  (ActivityThread.java:112)
  E/AndroidRuntime( 1426):        at 
  android.app.ActivityThread$H.handleMessage
  (ActivityThread.java:1581)
  E/AndroidRuntime( 1426):        at android.os.Handler.dispatchMessage
  (Handler.java:88)
  E/AndroidRuntime( 1426):        at android.os.Looper.loop(Looper.java:123)
  E/AndroidRuntime( 1426):        at android.app.ActivityThread.main
  (ActivityThread.java:3739)
  E/AndroidRuntime( 1426):        at java.lang.reflect.Method.invokeNative
  (Native Method)
  E/AndroidRuntime( 1426):        at java.lang.reflect.Method.invoke
  (Method.java:515)
  E/AndroidRuntime( 1426):        at com.android.internal.os.ZygoteInit
  $MethodAndArgsCaller.run(ZygoteInit.java:739)
  E/AndroidRuntime( 1426):        at com.android.internal.os.ZygoteInit.main
  (ZygoteInit.java:497)
  E/AndroidRuntime( 1426):        at dalvik.system.NativeStart.main(Native
  Method)
  E/AndroidRuntime( 1426): Caused by: java.lang.NullPointerException
  E/AndroidRuntime( 1426):        at com.getincontext.InContext.onCreate
  (InContext.java:51)
  E/AndroidRuntime( 1426):        at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
  1122)
  E/AndroidRuntime( 1426):        at
  android.app.ActivityThread.performLaunchActiv

  I searched in the other posts something similar, and It seems that it
  must be because the ImageButton is set tonull.

  Unfortunately I can't find anything that would lead to it in the XML
  or the Java code. The button is displayed properly and eclipse does
  not detect any error. I guess this is runtime.

  I tried to cast from ImageButton to button but it doesn't change
  anything. So I image the  trouble is from findViewById(), but arrow to
  exists, is a regular pgn file and is displayed by the emulator if this
  line is commented.

  The weirdest is that I got a similar statement just above, and I can't
  see any difference.

  Any clue ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null pointer exception while using setOnClickListener

2009-04-07 Thread e-satis

Update : Reading other posts, I tried to trash the R.java file but it
was not the cause.

On 7 avr, 19:48, e-satis info.ksam...@googlemail.com wrote:
 Hi,

 My java code look like this :

         // right_arrow button
         ImageButton arrow_button = (ImageButton)findViewById
 (R.id.arrow);
         arrow_button.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                  ((View)v.getParent().getParent()).setSelected(true);
             }
         });

 And the corresponding XML look like :

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:id=@+id/row_layout 

     LinearLayout android:id=@+id/row_checkbox_container

         CheckBox android:id=@+id/row_checkbox /

     /LinearLayout

    LinearLayout android:id=@+id/item_title_container

         TextView android:id=@+id/item_title/

     /LinearLayout

     LinearLayout android:id=@+id/right_arrow_container 

      ImageButton android:id=@+id/arrow
                     android:layout_width=18px
                     android:layout_height=fill_parent
                     android:layout_gravity=bottom
                     android:layout_weight=1
                     android:src=@drawable/arrow
                     android:background=#/

     /LinearLayout

 /LinearLayout

 I got anullpointerexceptionright after running the app in the
 emulator from eclipse on Ubuntu 8.10 :

 E/AndroidRuntime( 1426): java.lang.RuntimeException: Unable to start
 activity ComponentInfo{com.getincontext/com.getincontext.InContext}:
 java.lang.NullPointerException
 E/AndroidRuntime( 1426):        at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2141)
 E/AndroidRuntime( 1426):        at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
 2157)
 E/AndroidRuntime( 1426):        at android.app.ActivityThread.access$1800
 (ActivityThread.java:112)
 E/AndroidRuntime( 1426):        at android.app.ActivityThread$H.handleMessage
 (ActivityThread.java:1581)
 E/AndroidRuntime( 1426):        at android.os.Handler.dispatchMessage
 (Handler.java:88)
 E/AndroidRuntime( 1426):        at android.os.Looper.loop(Looper.java:123)
 E/AndroidRuntime( 1426):        at android.app.ActivityThread.main
 (ActivityThread.java:3739)
 E/AndroidRuntime( 1426):        at java.lang.reflect.Method.invokeNative
 (Native Method)
 E/AndroidRuntime( 1426):        at java.lang.reflect.Method.invoke
 (Method.java:515)
 E/AndroidRuntime( 1426):        at com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:739)
 E/AndroidRuntime( 1426):        at com.android.internal.os.ZygoteInit.main
 (ZygoteInit.java:497)
 E/AndroidRuntime( 1426):        at dalvik.system.NativeStart.main(Native
 Method)
 E/AndroidRuntime( 1426): Caused by: java.lang.NullPointerException
 E/AndroidRuntime( 1426):        at com.getincontext.InContext.onCreate
 (InContext.java:51)
 E/AndroidRuntime( 1426):        at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
 1122)
 E/AndroidRuntime( 1426):        at
 android.app.ActivityThread.performLaunchActiv

 I searched in the other posts something similar, and It seems that it
 must be because the ImageButton is set tonull.

 Unfortunately I can't find anything that would lead to it in the XML
 or the Java code. The button is displayed properly and eclipse does
 not detect any error. I guess this is runtime.

 I tried to cast from ImageButton to button but it doesn't change
 anything. So I image the  trouble is from findViewById(), but arrow to
 exists, is a regular pgn file and is displayed by the emulator if this
 line is commented.

 The weirdest is that I got a similar statement just above, and I can't
 see any difference.

 Any clue ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null pointer exception in MapActivity

2009-03-13 Thread Eric Chan
check the Manifest file
Best Regards

Eric Chan


On Fri, Mar 13, 2009 at 3:48 PM, olko y.olkho...@gmail.com wrote:


 I am using a procedure described here:

 http://developer.android.com/guide/tutorials/views/hello-mapview.html
 http://androidguys.com/?p=1413

 http://groups.google.com/group/android-developers/browse_thread/thread/fe23998c189ebcbd/38bab7cdd70598f7?lnk=gstq=getOverlays#38bab7cdd70598f7

 to create am instance of MapActivity and put on the map
 zoom controls, my location overlay and a number of subclassed itemized
 overlays.

 Everything seems to work except one little problem.
 As soon as I put subclassed itemized overlayes on the map
 and click the map instead of  the zoom controls I get Null pointer
 exception.

 Any ideas?





 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception

2008-06-23 Thread dolan kundu
Hi kenishant,

When a java file will create , in that case, only one (1) time
setContentView (R.layout.abcd) you can create.
And another case is, there must be some what mismatch with the java file and
the xml file.
so in these cases, NullPointerException can come.

Thanks,
Dolan.

On Sat, Jun 21, 2008 at 4:59 PM, redhatab [EMAIL PROTECTED] wrote:


 Hi,

 Am a total beginner and I was trying out to extrapolate on the Hello
 Android code, but I've sort of hit a road block with a null pointer
 exception. The code is as below:

 public class HelloAndroid extends Activity
 {
   @Override
   public void onCreate(Bundle icicle)
   {
   super.onCreate(icicle);

   setContentView(R.layout.screen1);

   Button btn = (Button) findViewById(R.id.hellobtn);
   btn.setOnClickListener(new View.OnClickListener() {
 public void onClick(View view) {
 setContentView(R.layout.screen2);
 }
 });
   }
 }

 As soon as I run this, the emulator gives me a null pointer exception.

 The res/layout/screen1.xml and res/layout/screen2.xml are working
 perfectly fine because when I just run
 setContentView(R.layout.screen1) without the onClickListener, both the
 screens work fine.

 I suppose the null pointer exception pops in the onClick function.

 Pls help!!
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception

2008-06-21 Thread Mark Murphy

redhatab wrote:
 Hi,
 
 Am a total beginner and I was trying out to extrapolate on the Hello
 Android code, but I've sort of hit a road block with a null pointer
 exception. The code is as below:
 
 public class HelloAndroid extends Activity
 {
  @Override
  public void onCreate(Bundle icicle)
  {
  super.onCreate(icicle);
 
  setContentView(R.layout.screen1);
 
  Button btn = (Button) findViewById(R.id.hellobtn);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setContentView(R.layout.screen2);
}
});
  }
 }
 
 As soon as I run this, the emulator gives me a null pointer exception.
 
 The res/layout/screen1.xml and res/layout/screen2.xml are working
 perfectly fine because when I just run
 setContentView(R.layout.screen1) without the onClickListener, both the
 screens work fine.
 
 I suppose the null pointer exception pops in the onClick function.

If you get the exception as soon as you run the program in the emulator, 
it can't be *inside* onClick(), as you would not have clicked anything yet.

More likely, btn is not getting set, because findViewById() is returning 
null, which would occur if R.id.hellobtn isn't in R.layout.screen1. The 
fact that your code compiles means that R.id.hellobtn probably exists 
somewhere...maybe in screen2?

Use adb logcat (or the Eclipse equivalent) to get a stacktrace to see 
where you're failing.

If you can't find the problem, post the XML layouts associated with this 
activity, and the stacktrace, and that may give us more clues.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions,  ebook formats, just $35/year

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception

2008-06-21 Thread Zach Hobbs

Just a tip on NullPointerExceptions:  if you are using eclipse in debug mode 
there is a pane for your Breakpoints.  In this pane there is a button that 
looks like J! and it will let you add an exception to your breakpoint list.  
This will cause your app to pause whenever this exception is thrown while 
debugging your app.  This is a good way to determine what may be happening.

Also, the line number will be available if you look at the LogCat output.

-- 

Zach Hobbs
HelloAndroid.com
Android OS news, tutorials, downloads 



On Saturday 21 June 2008 07:29:02 redhatab wrote:
 Hi,

 Am a total beginner and I was trying out to extrapolate on the Hello
 Android code, but I've sort of hit a road block with a null pointer
 exception. The code is as below:

 public class HelloAndroid extends Activity
 {
  @Override
  public void onCreate(Bundle icicle)
  {
  super.onCreate(icicle);

  setContentView(R.layout.screen1);

  Button btn = (Button) findViewById(R.id.hellobtn);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setContentView(R.layout.screen2);
}
});
  }
 }

 As soon as I run this, the emulator gives me a null pointer exception.

 The res/layout/screen1.xml and res/layout/screen2.xml are working
 perfectly fine because when I just run
 setContentView(R.layout.screen1) without the onClickListener, both the
 screens work fine.

 I suppose the null pointer exception pops in the onClick function.

 Pls help!!
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null pointer Exception while accessing Textfile

2008-05-10 Thread Dan U.

Without knowing more about your code, I'd say activity is null.

On May 10, 2:51 am, Analdin Judy [EMAIL PROTECTED] wrote:
 Hi,

Can anybody please tell me the reason for null pointer exception while
 reading a textfile
 I use the below code to read the textfile in raw.

activity.getResources().openRawResource(R.raw.*judy*);

 --
 Thanks  Regards

 Analdin Judy.M
 InfoWave
 Knowledgeware. Beyond Multimedia
 Chennai | INDIA
 M: +91.98416.64705www.i-waves.com

 The information contained in this e-mail (including any attachments) is
 intended by InfoWave for the use of the named individual or entity to which
 it is directed and is CONFIDENTIAL or PRIVILEGED. If you have received this
 e-mail (including any attachments) in error, please do not review, disclose,
 disseminate, distribute or copy this e-mail and attachments. As Electronic
 and Internet communications can be interfered with or affected by viruses
 and other defects, please scan this message and any attachments
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception on simple People query

2008-05-07 Thread kingkung

I'm sorry, it's not that it returs a null pointer exception, it's that
when I query the People database on my second activity, cursor.first()
returns false!!!  All of the people are still in the database
(nothing's changed)... why would the query from my first activity
return the list of People, and an identical query return nothing?

I'm very puzzled.

Thanks,

James

On May 6, 8:03 pm, Ahmet A. Akin [EMAIL PROTECTED] wrote:
 maybe you should write the stack trace.

 On Tue, May 6, 2008 at 9:29 PM, kingkung [EMAIL PROTECTED] wrote:

   Hey all,

   Not sure what Im doing wrong...

   I have a dbHelper which makes a query for all of the rows in People.

   When I do this query in my first activity, initializing dbHelper with
   that activity, I get all the people as I am supposed to.

   However, when I do the query in my second activity, with its own
   dbHelper initialized on its own activity, the cursor is assigned
   null!!  I call cursor.first(), and the app throws an NPE.

   Nothing about the People database has changed... the table is the same
   between the first and second activity.

   Anyone know what is going on???

   Thanks,

   James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null Pointer Exception on simple People query

2008-05-06 Thread Ahmet A. Akin

maybe you should write the stack trace.

On Tue, May 6, 2008 at 9:29 PM, kingkung [EMAIL PROTECTED] wrote:

  Hey all,

  Not sure what Im doing wrong...

  I have a dbHelper which makes a query for all of the rows in People.

  When I do this query in my first activity, initializing dbHelper with
  that activity, I get all the people as I am supposed to.

  However, when I do the query in my second activity, with its own
  dbHelper initialized on its own activity, the cursor is assigned
  null!!  I call cursor.first(), and the app throws an NPE.

  Nothing about the People database has changed... the table is the same
  between the first and second activity.

  Anyone know what is going on???

  Thanks,

  James

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Null pointer exception when finding views by Id

2008-03-31 Thread kaiping

Thanks for the help.  I finally just trashed both the xml and class
files and rewrote then.  It works now, I think it had to do with the
DatePicker.  Thanks for the help.

KaiPing

On Mar 28, 8:07 pm, Peli [EMAIL PROTECTED] wrote:
 Which is the line that causes the null-pointer exception? The code
 lines you posted surely don't as they just assign the values. How do
 you know that the values are 'null' in onCreate()?
 What is in EditTransaction.java:47 ?

 Peli

 On Mar 28, 12:38 pm,kaiping[EMAIL PROTECTED] wrote:

  OK, Did that and it still has the same error

  On Mar 27, 11:43 pm, Peli [EMAIL PROTECTED] wrote:

   Sometimes R.java is corrupted. It helps to clean everything either
   from within Eclipse or manually (delete bin/ and R.java) and rebuild
   from scratch.

   Peli

   On Mar 27, 2:44 pm,kaiping[EMAIL PROTECTED] wrote:

I am sure, Actually the R.id.account_name was a type I forgot to fix.
But, even the once that are in there return null.

On Mar 27, 12:16 am, Dan U. [EMAIL PROTECTED] wrote:

 Are you sure ALL the findViewById return null? This one does for sure:
 mDescription = (EditText) findViewById(R.id.account_name); since there
 is no account_name id in your layout.

 On Mar 26, 6:19 am,kaiping[EMAIL PROTECTED] wrote:

  Thanks for the idea.  I have confirmed that the file is named
  transaction_edit.xml.

  On Mar 26, 3:54 am, Dan U. [EMAIL PROTECTED] wrote:

   Well, he needs to have the filename be transaction_edit.xml. Not 
   sure
   if it is.

   On Mar 25, 5:29 am, Rick Genter [EMAIL PROTECTED] wrote:

Don't you need to name your layout transaction_edit in the 
XML file?

On Mar 25, 2008, at 5:26 AM,kaipingwrote:

 Hi, For one of my Activities All the findViewById() function 
 returns
 is null.  I am really astonished by this behaviour because 
 this same
 function works fine in other parts of my application.  I have 
 posted
 the code below.  If anybody has any ideas that would be great 
 thanks,

 Josh

 package com.jingsys.money;

 import java.util.ArrayList;

 import android.app.Activity;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.widget.ArrayAdapter;
 import android.widget.DatePicker;
 import android.widget.EditText;
 import android.widget.Spinner;

 import com.jingsys.money.data.AccountsDbAdapter;
 import com.jingsys.money.data.MoneyDbAdapterFactory;
 import com.jingsys.money.data.TransactionDbAdapter;

 public class EditTransaction extends Activity {

private  DatePicker mDate;
private  EditText mDescription;
private  EditText mNumber;
private  EditText mAmount;
private  Spinner mFromAccount;
private  Spinner mToAccount;
private  EditText mComments;

private TransactionDbAdapter transData;
private AccountsDbAdapter accountData;

private Cursor mFrom;
private Cursor mTo;

@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.transaction_edit);

mDate = (DatePicker) findViewById(R.id.trans_date);
mDescription = (EditText) 
 findViewById(R.id.account_name);
mNumber = (EditText) 
 findViewById(R.id.trans_number);
mAmount = (EditText) 
 findViewById(R.id.trans_amount);
mComments = (EditText) 
 findViewById(R.id.trans_comments);

mFromAccount = (Spinner) 
 findViewById(R.id.trans_from);
mToAccount = (Spinner) findViewById(R.id.trans_to);

 XML file
 ?xml version=1.0 encoding=UTF-8?
 TableLayout 
 xmlns:android=http://schemas.android.com/apk/res/
 android
android:layout_width=fill_parent
android:layout_height=fill_parent
android:stretchColumns=1
TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_date /
DatePicker android:id=@+id/trans_date
  android:layout_width=wrap_content
android:layout_height=wrap_content /
/TableRow

TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content

 android:text=@string/transaction_description /
EditText android:id=@+id/trans_descr
android:layout_width=wrap_content
 

[android-developers] Re: Null pointer exception when finding views by Id

2008-03-27 Thread kaiping

I am sure, Actually the R.id.account_name was a type I forgot to fix.
But, even the once that are in there return null.

On Mar 27, 12:16 am, Dan U. [EMAIL PROTECTED] wrote:
 Are you sure ALL the findViewById return null? This one does for sure:
 mDescription = (EditText) findViewById(R.id.account_name); since there
 is no account_name id in your layout.

 On Mar 26, 6:19 am,kaiping[EMAIL PROTECTED] wrote:

  Thanks for the idea.  I have confirmed that the file is named
  transaction_edit.xml.

  On Mar 26, 3:54 am, Dan U. [EMAIL PROTECTED] wrote:

   Well, he needs to have the filename be transaction_edit.xml. Not sure
   if it is.

   On Mar 25, 5:29 am, Rick Genter [EMAIL PROTECTED] wrote:

Don't you need to name your layout transaction_edit in the XML file?

On Mar 25, 2008, at 5:26 AM,kaipingwrote:

 Hi, For one of my Activities All the findViewById() function returns
 is null.  I am really astonished by this behaviour because this same
 function works fine in other parts of my application.  I have posted
 the code below.  If anybody has any ideas that would be great thanks,

 Josh

 package com.jingsys.money;

 import java.util.ArrayList;

 import android.app.Activity;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.widget.ArrayAdapter;
 import android.widget.DatePicker;
 import android.widget.EditText;
 import android.widget.Spinner;

 import com.jingsys.money.data.AccountsDbAdapter;
 import com.jingsys.money.data.MoneyDbAdapterFactory;
 import com.jingsys.money.data.TransactionDbAdapter;

 public class EditTransaction extends Activity {

private  DatePicker mDate;
private  EditText mDescription;
private  EditText mNumber;
private  EditText mAmount;
private  Spinner mFromAccount;
private  Spinner mToAccount;
private  EditText mComments;

private TransactionDbAdapter transData;
private AccountsDbAdapter accountData;

private Cursor mFrom;
private Cursor mTo;

@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.transaction_edit);

mDate = (DatePicker) findViewById(R.id.trans_date);
mDescription = (EditText) findViewById(R.id.account_name);
mNumber = (EditText) findViewById(R.id.trans_number);
mAmount = (EditText) findViewById(R.id.trans_amount);
mComments = (EditText) findViewById(R.id.trans_comments);

mFromAccount = (Spinner) findViewById(R.id.trans_from);
mToAccount = (Spinner) findViewById(R.id.trans_to);

 XML file
 ?xml version=1.0 encoding=UTF-8?
 TableLayout xmlns:android=http://schemas.android.com/apk/res/
 android
android:layout_width=fill_parent
android:layout_height=fill_parent
android:stretchColumns=1
TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_date /
DatePicker android:id=@+id/trans_date
  android:layout_width=wrap_content
android:layout_height=wrap_content /
/TableRow

TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_description /
EditText android:id=@+id/trans_descr
android:layout_width=wrap_content
android:layout_height=wrap_content/
/TableRow

TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_number/
EditText android:id=@+id/trans_number
android:layout_width=wrap_content
android:layout_height=wrap_content/
/TableRow

TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_amount/
EditText android:id=@+id/trans_amount
android:layout_width=wrap_content
android:layout_height=wrap_content/
/TableRow

TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/transaction_from/
Spinner android:id=@+id/trans_from
android:layout_width=wrap_content
android:layout_height=fill_parent/
/TableRow

TableRow
TextView 

[android-developers] Re: Null pointer exception when finding views by Id

2008-03-27 Thread Peli

Sometimes R.java is corrupted. It helps to clean everything either
from within Eclipse or manually (delete bin/ and R.java) and rebuild
from scratch.

Peli

On Mar 27, 2:44 pm, kaiping [EMAIL PROTECTED] wrote:
 I am sure, Actually the R.id.account_name was a type I forgot to fix.
 But, even the once that are in there return null.

 On Mar 27, 12:16 am, Dan U. [EMAIL PROTECTED] wrote:

  Are you sure ALL the findViewById return null? This one does for sure:
  mDescription = (EditText) findViewById(R.id.account_name); since there
  is no account_name id in your layout.

  On Mar 26, 6:19 am,kaiping[EMAIL PROTECTED] wrote:

   Thanks for the idea.  I have confirmed that the file is named
   transaction_edit.xml.

   On Mar 26, 3:54 am, Dan U. [EMAIL PROTECTED] wrote:

Well, he needs to have the filename be transaction_edit.xml. Not sure
if it is.

On Mar 25, 5:29 am, Rick Genter [EMAIL PROTECTED] wrote:

 Don't you need to name your layout transaction_edit in the XML file?

 On Mar 25, 2008, at 5:26 AM,kaipingwrote:

  Hi, For one of my Activities All the findViewById() function returns
  is null.  I am really astonished by this behaviour because this same
  function works fine in other parts of my application.  I have posted
  the code below.  If anybody has any ideas that would be great 
  thanks,

  Josh

  package com.jingsys.money;

  import java.util.ArrayList;

  import android.app.Activity;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.widget.ArrayAdapter;
  import android.widget.DatePicker;
  import android.widget.EditText;
  import android.widget.Spinner;

  import com.jingsys.money.data.AccountsDbAdapter;
  import com.jingsys.money.data.MoneyDbAdapterFactory;
  import com.jingsys.money.data.TransactionDbAdapter;

  public class EditTransaction extends Activity {

 private  DatePicker mDate;
 private  EditText mDescription;
 private  EditText mNumber;
 private  EditText mAmount;
 private  Spinner mFromAccount;
 private  Spinner mToAccount;
 private  EditText mComments;

 private TransactionDbAdapter transData;
 private AccountsDbAdapter accountData;

 private Cursor mFrom;
 private Cursor mTo;

 @Override
 protected void onCreate(Bundle icicle) {
 super.onCreate(icicle);
 setContentView(R.layout.transaction_edit);

 mDate = (DatePicker) findViewById(R.id.trans_date);
 mDescription = (EditText) 
  findViewById(R.id.account_name);
 mNumber = (EditText) findViewById(R.id.trans_number);
 mAmount = (EditText) findViewById(R.id.trans_amount);
 mComments = (EditText) findViewById(R.id.trans_comments);

 mFromAccount = (Spinner) findViewById(R.id.trans_from);
 mToAccount = (Spinner) findViewById(R.id.trans_to);

  XML file
  ?xml version=1.0 encoding=UTF-8?
  TableLayout xmlns:android=http://schemas.android.com/apk/res/
  android
 android:layout_width=fill_parent
 android:layout_height=fill_parent
 android:stretchColumns=1
 TableRow
 TextView android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text=@string/transaction_date /
 DatePicker android:id=@+id/trans_date
   android:layout_width=wrap_content
 android:layout_height=wrap_content /
 /TableRow

 TableRow
 TextView android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text=@string/transaction_description /
 EditText android:id=@+id/trans_descr
 android:layout_width=wrap_content
 android:layout_height=wrap_content/
 /TableRow

 TableRow
 TextView android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text=@string/transaction_number/
 EditText android:id=@+id/trans_number
 android:layout_width=wrap_content
 android:layout_height=wrap_content/
 /TableRow

 TableRow
 TextView android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text=@string/transaction_amount/
 EditText android:id=@+id/trans_amount
 android:layout_width=wrap_content
 android:layout_height=wrap_content/
 /TableRow

 TableRow
 TextView android:layout_width=wrap_content
 

[android-developers] Re: Null pointer exception when finding views by Id

2008-03-26 Thread kaiping

Thanks for the idea.  I have confirmed that the file is named
transaction_edit.xml.

On Mar 26, 3:54 am, Dan U. [EMAIL PROTECTED] wrote:
 Well, he needs to have the filename be transaction_edit.xml. Not sure
 if it is.

 On Mar 25, 5:29 am, Rick Genter [EMAIL PROTECTED] wrote:

  Don't you need to name your layout transaction_edit in the XML file?

  On Mar 25, 2008, at 5:26 AM,kaipingwrote:

   Hi, For one of my Activities All the findViewById() function returns
   is null.  I am really astonished by this behaviour because this same
   function works fine in other parts of my application.  I have posted
   the code below.  If anybody has any ideas that would be great thanks,

   Josh

   package com.jingsys.money;

   import java.util.ArrayList;

   import android.app.Activity;
   import android.database.Cursor;
   import android.os.Bundle;
   import android.widget.ArrayAdapter;
   import android.widget.DatePicker;
   import android.widget.EditText;
   import android.widget.Spinner;

   import com.jingsys.money.data.AccountsDbAdapter;
   import com.jingsys.money.data.MoneyDbAdapterFactory;
   import com.jingsys.money.data.TransactionDbAdapter;

   public class EditTransaction extends Activity {

  private  DatePicker mDate;
  private  EditText mDescription;
  private  EditText mNumber;
  private  EditText mAmount;
  private  Spinner mFromAccount;
  private  Spinner mToAccount;
  private  EditText mComments;

  private TransactionDbAdapter transData;
  private AccountsDbAdapter accountData;

  private Cursor mFrom;
  private Cursor mTo;

  @Override
  protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.transaction_edit);

  mDate = (DatePicker) findViewById(R.id.trans_date);
  mDescription = (EditText) findViewById(R.id.account_name);
  mNumber = (EditText) findViewById(R.id.trans_number);
  mAmount = (EditText) findViewById(R.id.trans_amount);
  mComments = (EditText) findViewById(R.id.trans_comments);

  mFromAccount = (Spinner) findViewById(R.id.trans_from);
  mToAccount = (Spinner) findViewById(R.id.trans_to);

   XML file
   ?xml version=1.0 encoding=UTF-8?
   TableLayout xmlns:android=http://schemas.android.com/apk/res/
   android
  android:layout_width=fill_parent
  android:layout_height=fill_parent
  android:stretchColumns=1
  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_date /
  DatePicker android:id=@+id/trans_date
android:layout_width=wrap_content
  android:layout_height=wrap_content /
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_description /
  EditText android:id=@+id/trans_descr
  android:layout_width=wrap_content
  android:layout_height=wrap_content/
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_number/
  EditText android:id=@+id/trans_number
  android:layout_width=wrap_content
  android:layout_height=wrap_content/
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_amount/
  EditText android:id=@+id/trans_amount
  android:layout_width=wrap_content
  android:layout_height=wrap_content/
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_from/
  Spinner android:id=@+id/trans_from
  android:layout_width=wrap_content
  android:layout_height=fill_parent/
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_to/
  Spinner android:id=@+id/trans_to
  android:layout_width=wrap_content
  android:layout_height=fill_parent/
  /TableRow

  TableRow
  TextView android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=@string/transaction_comments/
  EditText android:id=@+id/trans_comments