In the method below, NasaDailyFragment is always null in the debugger. The method call NasaDailyFragment.onRefresh(); fails using because of this. I can't figure out why its null.
public class NasaAppActivity extends FragmentActivity {
//other methods
public void onRefreshClicked(View view){
Log.d("debug", "in run");
FragmentManager fragmentManager=getSupportFragmentManager();
NasaDailyImage NasaDailyFragment=(NasaDailyImage)fragmentManager.findFragmentById(R.id.fragment_iotd);
if(NasaDailyFragment!=null){
Log.d("debug", "fragment has been casted and is NOT null!!!");
}
NasaDailyFragment.onRefresh();//always crashes here because NasaDailyFragment is null, this is "line 40" of the code
}
}
Here's the xml for the fragment defined by R.id.fragment_iotd
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment android:name="com.wajumbie.nasadailyimage.NasaDailyImage"
android:id="#+id/fragment_iotd"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
The logcat output
07-19 11:21:25.916: D/debug(534): in run
07-19 11:21:25.916: D/AndroidRuntime(534): Shutting down VM
07-19 11:21:25.916: W/dalvikvm(534): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
07-19 11:21:25.936: E/AndroidRuntime(534): FATAL EXCEPTION: main
07-19 11:21:25.936: E/AndroidRuntime(534): java.lang.IllegalStateException: Could not execute method of the activity
07-19 11:21:25.936: E/AndroidRuntime(534): at android.view.View$1.onClick(View.java:3044)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.view.View.performClick(View.java:3511)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.view.View$PerformClick.run(View.java:14105)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.os.Handler.handleCallback(Handler.java:605)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.os.Handler.dispatchMessage(Handler.java:92)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.os.Looper.loop(Looper.java:137)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-19 11:21:25.936: E/AndroidRuntime(534): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 11:21:25.936: E/AndroidRuntime(534): at java.lang.reflect.Method.invoke(Method.java:511)
07-19 11:21:25.936: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-19 11:21:25.936: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-19 11:21:25.936: E/AndroidRuntime(534): at dalvik.system.NativeStart.main(Native Method)
07-19 11:21:25.936: E/AndroidRuntime(534): Caused by: java.lang.reflect.InvocationTargetException
07-19 11:21:25.936: E/AndroidRuntime(534): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 11:21:25.936: E/AndroidRuntime(534): at java.lang.reflect.Method.invoke(Method.java:511)
07-19 11:21:25.936: E/AndroidRuntime(534): at android.view.View$1.onClick(View.java:3039)
07-19 11:21:25.936: E/AndroidRuntime(534): ... 11 more
07-19 11:21:25.936: E/AndroidRuntime(534): Caused by: java.lang.NullPointerException
07-19 11:21:25.936: E/AndroidRuntime(534): at com.wajumbie.nasadailyimage.NasaAppActivity.onRefreshClicked(NasaAppActivity.java:40)
07-19 11:21:25.936: E/AndroidRuntime(534): ... 14 more
07-19 11:21:26.556: I/dalvikvm(534): threadid=3: reacting to signal 3
07-19 11:21:26.586: I/dalvikvm(534): Wrote stack traces to '/data/anr/traces.txt'
Related
We tried integrating HelpStack by following steps given on GitHub, but we kept getting the following errors:
04-03 13:54:22.054 4638-4638/com.playerline.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.playerline.android/com.tenmiles.helpstack.activities.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.tenmiles.helpstack.activities.HSActivityParent.onCreate(HSActivityParent.java:48)
at com.tenmiles.helpstack.activities.HomeActivity.onCreate(HomeActivity.java:46)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
I'm guessing it has something to do with the App Theme, which in our case is is Theme.AppCompat.NoActionBar.
We have problem related with Imsdroid Integration with my android application.During the application startup it gives error as follow..
ExceptionInInitializerError
My log file is:
07-19 19:55:58.047: E/AndroidRuntime(6858): FATAL EXCEPTION: main
07-19 19:55:58.047: E/AndroidRuntime(6858): java.lang.ExceptionInInitializerError
07-19 19:55:58.047: E/AndroidRuntime(6858): at org.doubango.imsdroid.MyMainClass.<init>(MyMainClass.java:43)
07-19 19:55:58.047: E/AndroidRuntime(6858): at java.lang.Class.newInstanceImpl(Native Method)
07-19 19:55:58.047: E/AndroidRuntime(6858): at java.lang.Class.newInstance(Class.java:1319)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.ActivityThread.access$600(ActivityThread.java:149)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.os.Looper.loop(Looper.java:153)
07-19 19:55:58.047: E/AndroidRuntime(6858): at android.app.ActivityThread.main(ActivityThread.java:4987)
07-19 19:55:58.047: E/AndroidRuntime(6858): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 19:55:58.047: E/AndroidRuntime(6858): at java.lang.reflect.Method.invoke(Method.java:511)
07-19 19:55:58.047: E/AndroidRuntime(6858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
07-19 19:55:58.047: E/AndroidRuntime(6858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
07-19 19:55:58.047: E/AndroidRuntime(6858): at dalvik.system.NativeStart.main(Native Method)
07-19 19:55:58.047: E/AndroidRuntime(6858): Caused by: java.lang.NullPointerException
07-19 19:55:58.047: E/AndroidRuntime(6858): at org.doubango.ngn.NgnEngine.<clinit>(NgnEngine.java:75)
07-19 19:55:58.047: E/AndroidRuntime(6858): ... 16 more
I think its with your AndroidManifest. Try putting this on your Application tag
android:name="org.doubango.ngn.NgnApplication"
or
if you have a custom Application object extend NgnApplication object instead of Application object.
If you want to use imsdroid in your application then you need to use ChromeView instead of WebView in android xml file.
I found more information and at here
<us.costan.chrome.ChromeView
android:id="#+id/customWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
I'm new to android, now i want to press a button then display text on the screen. here's my code:
xml
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendMessages"
android:text="Button" />
<TextView
android:id="#+id/buttonText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:ems="10"
android:inputType="textMultiLine"
android:text="hello" />
main activity
public class MainActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState){
.......
}
public void sendMessages(View view) {
TextView welcome = (TextView) findViewById(R.id.buttonText);
welcome.setText("button clicked");
}
}
but when i run this on a simulator, after pressing the button, the application will report
fortunately, First Android App has stopped
does anyone know what's wrong with my program?
04-18 00:56:20.147: D/AndroidRuntime(1280): Shutting down VM
04-18 00:56:20.147: W/dalvikvm(1280): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
04-18 00:56:20.177: E/AndroidRuntime(1280): FATAL EXCEPTION: main
04-18 00:56:20.177: E/AndroidRuntime(1280): java.lang.IllegalStateException: Could not execute method of the activity
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.view.View$1.onClick(View.java:3591)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.view.View.performClick(View.java:4084)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.view.View$PerformClick.run(View.java:16966)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.os.Handler.handleCallback(Handler.java:615)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.os.Handler.dispatchMessage(Handler.java:92)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.os.Looper.loop(Looper.java:137)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-18 00:56:20.177: E/AndroidRuntime(1280): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 00:56:20.177: E/AndroidRuntime(1280): at java.lang.reflect.Method.invoke(Method.java:511)
04-18 00:56:20.177: E/AndroidRuntime(1280): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-18 00:56:20.177: E/AndroidRuntime(1280): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-18 00:56:20.177: E/AndroidRuntime(1280): at dalvik.system.NativeStart.main(Native Method)
04-18 00:56:20.177: E/AndroidRuntime(1280): Caused by: java.lang.reflect.InvocationTargetException
04-18 00:56:20.177: E/AndroidRuntime(1280): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 00:56:20.177: E/AndroidRuntime(1280): at java.lang.reflect.Method.invoke(Method.java:511)
04-18 00:56:20.177: E/AndroidRuntime(1280): at android.view.View$1.onClick(View.java:3586)
04-18 00:56:20.177: E/AndroidRuntime(1280): ... 11 more
04-18 00:56:20.177: E/AndroidRuntime(1280): Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.widget.TextView
04-18 00:56:20.177: E/AndroidRuntime(1280): at com.example.firstandroidapp.MainActivity.sendMessages(MainActivity.java:110)
04-18 00:56:20.177: E/AndroidRuntime(1280): ... 14 more
Do button and TextView exist in the activity layout?
Do you call setContentView(Layout) in onCreate?
Are you working with ADT?
If you are working with ADT you can create a new activity and
a new xml layout, so call setContentView(R.layout.YourLayout)
in onCreate
YourLayout.xml has to contains button and TextView
I'm trying to establish communication between Arduino UNO R3 and Galaxy SII on Android 4.1 cross usb. The code sample i am following i here: http://androidgurusolutions.blogspot.com/2012/07/arduino-adk-board-blink-led-with-your.html . Unfortunately, i am getting this message 'app has stopped' and here is LogCat error
LogCat:
E/AndroidRuntime(535): FATAL EXCEPTION: main
E/AndroidRuntime(535): java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
E/AndroidRuntime(535): at com.example.mypro.MainActivity.onCreate(MainActivity.java:123)
E/AndroidRuntime(535): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(535): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
E/AndroidRuntime(535): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(535):at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(535):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(535):at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(535):at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(535):at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(535):at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(535):at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(535):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(535):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(535):at dalvik.system.NativeStart.main(Native Method)
please can anybody help me. thanks in advance.....
Hello i am using the tabhost in my application it works fine in 4.0 and up but when i try to run it in 2.3.3 it returns me a null pointer exception and force closes the application
here is the code i am getting error in :
TextView t = new TextView(this) ;
t= (TextView) getTabWidget().getChildAt(i).findViewById(android.R.id.title);
t.setTextColor(Color. parseColor("#ffffff"));
if (i == 0) tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#00aedb"));
else tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#0d82df"));
this is my logcat output :
05-16 12:29:27.009: E/AndroidRuntime(534): FATAL EXCEPTION: main
05-16 12:29:27.009: E/AndroidRuntime(534): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.moneyminder/com.example.moneyminder.MainActivity}: java.lang.NullPointerException
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.os.Looper.loop(Looper.java:123)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-16 12:29:27.009: E/AndroidRuntime(534): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 12:29:27.009: E/AndroidRuntime(534): at java.lang.reflect.Method.invoke(Method.java:507)
05-16 12:29:27.009: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-16 12:29:27.009: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-16 12:29:27.009: E/AndroidRuntime(534): at dalvik.system.NativeStart.main(Native Method)
05-16 12:29:27.009: E/AndroidRuntime(534): Caused by: java.lang.NullPointerException
05-16 12:29:27.009: E/AndroidRuntime(534): at com.example.moneyminder.MainActivity.onCreate(MainActivity.java:78)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 12:29:27.009: E/AndroidRuntime(534): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-16 12:29:27.009: E/AndroidRuntime(534): ... 11 more