Here is my simple layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/my_long_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/long_text_str" />
<Button
android:id="#+id/capture_screen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="captureScreen"
android:text="Capture Screen" />
</LinearLayout>
</ScrollView>
the following code in captureScreen() function crashes the app:
TextView tv = (TextView) findViewById(R.id.my_long_textview);
tv.setDrawingCacheEnabled(true);
tv.buildDrawingCache(); // comment out this line makes no difference
bitmap = Bitmap.createBitmap(tv.getDrawingCache()); // this is line 31 in stack trace
tv.setDrawingCacheEnabled(false);
This code works but I really like to capture the entire TextView:
View rv = v.getRootView();
rv.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(rv.getDrawingCache());
rv.setDrawingCacheEnabled(false);
Stack Trace is as follows:
04-21 00:17:08.023: E/AndroidRuntime(27472): java.lang.IllegalStateException: Could not execute method of the activity
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$1.onClick(View.java:2072)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View.performClick(View.java:2408)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$PerformClick.run(View.java:8816)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Handler.handleCallback(Handler.java:587)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Handler.dispatchMessage(Handler.java:92)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.os.Looper.loop(Looper.java:123)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 00:17:08.023: E/AndroidRuntime(27472): at dalvik.system.NativeStart.main(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.reflect.InvocationTargetException
04-21 00:17:08.023: E/AndroidRuntime(27472): at com.gtgg.ui.TextViewAct.captureScreen(TextViewAct.java:31)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 00:17:08.023: E/AndroidRuntime(27472): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.view.View$1.onClick(View.java:2067)
04-21 00:17:08.023: E/AndroidRuntime(27472): ... 11 more
04-21 00:17:08.023: E/AndroidRuntime(27472): Caused by: java.lang.NullPointerException
04-21 00:17:08.023: E/AndroidRuntime(27472): at android.graphics.Bitmap.createBitmap(Bitmap.java:358)
04-21 00:17:08.023: E/AndroidRuntime(27472): ... 15 more
Is there a way to save the big text view into a bitmap, even though it's bigger than the rootView?
Thanks a lot!
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.
I am trying to write my first Android app, and I'm having trouble. I wrote a simple Java program to find the factors of a number provided by the user, and I'd like to port it over to Java. I have an XML file for the interface, which seemed to run OK until I added the first Java class. Now it won't run, and log.cat says that there's a null pointer exception. So far, I only have stubs, but it seems like it should run OK with what I've done to this point. I'm including the log.cat text, but I'm too new it this to make much sense out of it.
There may be more than one problem. After adding the Java file I began to get run-time errors right away, but I don't think they were null pointer exceptions. I think that started when I made changes to fix what was already causing problems.
Any help is appreciated.
Here is the Java file:
import android.app.Activity; <br>
import android.os.Bundle; <br>
import android.widget.Button; <br>
import android.widget.EditText; <br>
import android.widget.TextView; <br>
public class AndroidFactoringActivity extends Activity {
// Instance Variables
EditText userNumber;
Button factorButton;
TextView resultsField;
int factorResults;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
factorButton = (Button) findViewById(R.id.factorButton);
userNumber = (EditText) findViewById(R.id.userNumber);
factorResults = 1;
resultsField.setText(String.valueOf(factorResults));
}
}
Here is main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/askField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/ask"
android:textSize="24dp" />
<EditText
android:id="#+id/userNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="#+id/factorButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/click" />
<TextView
android:id="#+id/resultsField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/tell"
android:textSize="24dp" />
</LinearLayout>
Here are the log.cat results:
03-31 23:58:53.579: D/AndroidRuntime(2804): Shutting down VM
03-31 23:58:53.589: W/dalvikvm(2804): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-31 23:58:53.589: E/AndroidRuntime(2804): Uncaught handler: thread main exiting due to uncaught exception
03-31 23:58:53.650: E/AndroidRuntime(2804): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.os.Looper.loop(Looper.java:123)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): at java.lang.reflect.Method.invoke(Method.java:521)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-31 23:58:53.650: E/AndroidRuntime(2804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-31 23:58:53.650: E/AndroidRuntime(2804): at dalvik.system.NativeStart.main(Native Method)
03-31 23:58:53.650: E/AndroidRuntime(2804): Caused by: java.lang.NullPointerException
03-31 23:58:53.650: E/AndroidRuntime(2804): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 23:58:53.650: E/AndroidRuntime(2804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-31 23:58:53.650: E/AndroidRuntime(2804): ... 11 more
03-31 23:58:53.679: I/dalvikvm(2804): threadid=7: reacting to signal 3
03-31 23:58:53.679: E/dalvikvm(2804): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
03-31 23:59:57.629: I/Process(2804): Sending signal. PID: 2804 SIG: 9
04-01 00:07:36.129: D/AndroidRuntime(3040): Shutting down VM
04-01 00:07:36.129: W/dalvikvm(3040): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-01 00:07:36.139: E/AndroidRuntime(3040): Uncaught handler: thread main exiting due to uncaught exception
04-01 00:07:36.159: E/AndroidRuntime(3040): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.dave_b.factoring/net.dave_b.factoring.AndroidFactoringActivity}: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.os.Looper.loop(Looper.java:123)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): at java.lang.reflect.Method.invoke(Method.java:521)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-01 00:07:36.159: E/AndroidRuntime(3040): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-01 00:07:36.159: E/AndroidRuntime(3040): at dalvik.system.NativeStart.main(Native Method)
04-01 00:07:36.159: E/AndroidRuntime(3040): Caused by: java.lang.NullPointerException
04-01 00:07:36.159: E/AndroidRuntime(3040): at net.dave_b.factoring.AndroidFactoringActivity.onCreate(AndroidFactoringActivity.java:26)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-01 00:07:36.159: E/AndroidRuntime(3040): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-01 00:07:36.159: E/AndroidRuntime(3040): ... 11 more
04-01 00:07:36.199: I/dalvikvm(3040): threadid=7: reacting to signal 3
04-01 00:07:36.199: E/dalvikvm(3040): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-01 00:07:40.329: I/Process(3040): Sending signal. PID: 3040 SIG: 9
resultsField.setText(String.valueOf(factorResults));
resultsField is null and you are trying to set value on null.
resultsField= (TextView ) findViewById(R.id.userNumber);
Get textview instance before setting value, otherwise resultsField will be null and all operations on null reference results in NullPointerException.
You got a null pointer because you didnt intialise the variable resultsField (you just declared it) .
As you used
userNumber = (EditText) findViewById(R.id.userNumber);
you must even initialise the reference resultsField.
This can be done using
resultsField= (TextView ) findViewById(R.id.resultsField);
in the onCreate() after the statement setContentView()
You need to initialize the userNumer and resultsFiled as follows
userNumber = (EditText) findViewById(R.id.userNumber);
resultsField= (TextView ) findViewById(R.id.resultsField);
I'm getting the process stopped unexpectedly on emulator when i run my application. Here are my logcat details:
06-30 15:09:46.126: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 46K, 53% free 2551K/5379K, external 1625K/2137K, paused 72ms
06-30 15:09:50.146: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 51ms
06-30 15:09:51.196: D/AndroidRuntime(520): Shutting down VM
06-30 15:09:51.196: W/dalvikvm(520): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:09:51.217: E/AndroidRuntime(520): FATAL EXCEPTION: main
06-30 15:09:51.217: E/AndroidRuntime(520): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Looper.loop(Looper.java:123)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:09:51.217: E/AndroidRuntime(520): at dalvik.system.NativeStart.main(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): Caused by: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:09:51.217: E/AndroidRuntime(520): ... 11 more
06-30 15:09:54.516: I/Process(520): Sending signal. PID: 520 SIG: 9
06-30 15:17:01.117: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 48K, 53% free 2551K/5379K, external 1625K/2137K, paused 52ms
06-30 15:17:03.237: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 52ms
06-30 15:17:04.327: D/AndroidRuntime(539): Shutting down VM
06-30 15:17:04.327: W/dalvikvm(539): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:17:04.346: E/AndroidRuntime(539): FATAL EXCEPTION: main
06-30 15:17:04.346: E/AndroidRuntime(539): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Looper.loop(Looper.java:123)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:17:04.346: E/AndroidRuntime(539): at dalvik.system.NativeStart.main(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): Caused by: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:17:04.346: E/AndroidRuntime(539): ... 11 more
06-30 15:17:08.717: I/Process(539): Sending signal. PID: 539 SIG: 9
Looking at the log
15:17:04.346: E/AndroidRuntime(539): Caused by:
java.lang.NullPointerException 06-30 15:17:04.346:
E/AndroidRuntime(539): at
com.mesha.firstand.firstl.onCreate(firstl.java:16)
you will see that a NullPointerException is thrown in line 16 of your activity firstl.
Please post your code of the firstl activity if you need more help on that.
as after seeing your logcat these maybe possible
CASE 1: make sure you are setting right layout:
public class firstl extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The activity is being created.
setContentView(R.layout.main);//MAKE SURE YOU ARE SETTING RIGHT LAYOUT
}
CASE 2: make sure you are using right id for views accessing in code as define in xml layout
CASE 3: make sure you are registering Activity with right name in Manifest.xml :
<Activity android:name=".firstl" />
Im designing my first android application and keep coming up with the following error which is draining the life out of me and I do not understand it very well (Please find my Logcat (verbose), Java Code(this i played around with and this began to occur once started to work on my editButton and buttonUpdate bit. Does it have anything to do with the editStatus? I really think it may) and I have also put in my manifest file:
LOGCAT verbose
04-21 15:30:23.388: D/AndroidRuntime(276): Shutting down VM
04-21 15:30:23.388: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:30:23.427: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-21 15:30:23.427: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:30:23.427: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:30:23.427: E/AndroidRuntime(276): ... 11 more
04-21 15:35:23.607: I/Process(276): Sending signal. PID: 276 SIG: 9
04-21 15:50:32.127: D/AndroidRuntime(301): Shutting down VM
04-21 15:50:32.127: W/dalvikvm(301): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:50:32.147: E/AndroidRuntime(301): FATAL EXCEPTION: main
04-21 15:50:32.147: E/AndroidRuntime(301): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Looper.loop(Looper.java:123)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:50:32.147: E/AndroidRuntime(301): at dalvik.system.NativeStart.main(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:50:32.147: E/AndroidRuntime(301): ... 11 more
CODE:
package com.locator.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LocatorDemoActivity extends Activity implements OnClickListener {
EditText editStatus;
Button buttonUpdate;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationstatus);
editStatus = (EditText)findViewById(R.id.edit_status);
buttonUpdate = (Button)findViewById(R.id.button_update);
buttonUpdate.setOnClickListener(this);
//have button 'listen' for click
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
ANDROID Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.locator.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_main" >
<activity
android:name=".LocatorDemoActivity"
android:label="#string/app_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have;
attempted to do adb kill-server and adb start-server and run it with an without an emulator as suggested in another post. Please be slightly understanding as my knowledge of eclipse and Java is pretty low and im learning.
Please help
As seen from this error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}:
java.lang.ClassCastException: android.widget.TextView
And this one:
Caused by: java.lang.ClassCastException: android.widget.TextView
You are trying to cast a TextView to EditText ( in this line: editStatus = (EditText)findViewById(R.id.edit_status);).
Go to locationstatus.xml, and change the TextView with the id edit_status to EditText.
15 reports
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oas.fruitkungfufree/com.openfeint.internal.ui.IntroFlow}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.openfeint.internal.Util.setOrientation(Util.java:36)
at com.openfeint.internal.ui.NestedWindow.onCreate(NestedWindow.java:32)
at com.openfeint.internal.ui.WebNav.onCreate(WebNav.java:93)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
Does any one have a solution for this??
This is a problem with your code, you can't use an object that is null. This is a hint.