Android Socket Client closes itself [duplicate] - android

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
android.os.NetworkOnMainThreadException
Android Socket Client didn’t send and closes itself
i am new to java and android programming and i am trying to programm an Android Client and a server for my pc (windows 7). With this connection i want to send a string from pc to the android app and also from the app to the pc. I checked my server, whether it is programmed correctly and it is. So i must habe an error in my client. When i launch the app. The app starts but when i want to send a string from my app to the pc the app just closes itself. Now i need your help indeed. I have been programming just on the app for more than 2 days.
Here is my LogCat and i really hope that you can tell me where i can find my mistake.
12-28 21:10:29.348: I/dalvikvm(565): threadid=3: reacting to signal 3
12-28 21:10:29.428: I/dalvikvm(565): Wrote stack traces to '/data/anr/traces.txt'
12-28 21:10:29.818: I/dalvikvm(565): threadid=3: reacting to signal 3
12-28 21:10:29.888: I/dalvikvm(565): Wrote stack traces to '/data/anr/traces.txt'
12-28 21:10:30.258: D/gralloc_goldfish(565): Emulator without GPU emulation detected.
12-28 21:10:30.319: I/dalvikvm(565): threadid=3: reacting to signal 3
12-28 21:10:30.348: I/dalvikvm(565): Wrote stack traces to '/data/anr/traces.txt'
12-28 21:11:12.498: D/AndroidRuntime(565): Shutting down VM
12-28 21:11:12.508: W/dalvikvm(565): threadid=1: thread exiting with uncaught exception
(group=0x409c01f8)
12-28 21:11:12.540: E/AndroidRuntime(565): FATAL EXCEPTION: main
12-28 21:11:12.540: E/AndroidRuntime(565): android.os.NetworkOnMainThreadException
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
12-28 21:11:12.540: E/AndroidRuntime(565): at
libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
12-28 21:11:12.540: E/AndroidRuntime(565): at
libcore.io.IoBridge.connectErrno(IoBridge.java:127)
12-28 21:11:12.540: E/AndroidRuntime(565): at
libcore.io.IoBridge.connect(IoBridge.java:112)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.net.Socket.startupSocket(Socket.java:566)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.net.Socket.tryAllAddresses(Socket.java:127)
12-28 21:11:12.540: E/AndroidRuntime(565): at java.net.Socket.<init>(Socket.java:177)
12-28 21:11:12.540: E/AndroidRuntime(565): at java.net.Socket.<init>(Socket.java:149)
12-28 21:11:12.540: E/AndroidRuntime(565): at
net.ibasic.AndroidClient$1.onClick(AndroidClient.java:50)
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.view.View.performClick(View.java:3511)
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.view.View$PerformClick.run(View.java:14105)
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.os.Handler.handleCallback(Handler.java:605)
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.os.Handler.dispatchMessage(Handler.java:92)
12-28 21:11:12.540: E/AndroidRuntime(565): at android.os.Looper.loop(Looper.java:137)
12-28 21:11:12.540: E/AndroidRuntime(565): at
android.app.ActivityThread.main(ActivityThread.java:4424)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.lang.reflect.Method.invokeNative(Native Method)
12-28 21:11:12.540: E/AndroidRuntime(565): at
java.lang.reflect.Method.invoke(Method.java:511)
12-28 21:11:12.540: E/AndroidRuntime(565): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-28 21:11:12.540: E/AndroidRuntime(565): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-28 21:11:12.540: E/AndroidRuntime(565): at dalvik.system.NativeStart.main(Native
Method)
12-28 21:11:13.178: I/dalvikvm(565): threadid=3: reacting to signal 3
12-28 21:11:13.218: I/dalvikvm(565): Wrote stack traces to '/data/anr/traces.txt'
12-28 21:11:15.288: I/Process(565): Sending signal. PID: 565 SIG: 9

It sounds like you probably are doing the network stuff in main UI instead of background like AsyncTask
Here is a basic example of how it is set up
public class MyNetworkTask extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
}
#Override
protected String doInBackground(String... params) {
//do your work here
return something;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
// do something with data here-display it or send to mainactivity
}
Here is a link to the documentation for it:
http://developer.android.com/reference/android/os/AsyncTask.html

Related

Android - Unfortunately, myapp has stopped

I am learning to develop Android applications and have come across a problem with my app. I have created an app that will allow user to type some text and when a button is pressed, a function is called that performs parsing the input string to double and then displays it. I have received no errors, but whenever I run the app on any emulator, it says "Unfortunately, myapp has stopped".
Here is the LogCat:
04-04 14:34:11.579: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:11.969: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:12.089: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:12.720: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:12.860: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:12.979: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:13.069: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:13.479: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:13.599: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:14.009: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:14.129: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:14.320: D/libEGL(657): loaded /system/lib/egl/libGLES_android.so
04-04 14:34:14.390: D/libEGL(657): loaded /system/lib/egl/libEGL_emulation.so
04-04 14:34:14.409: D/(657): HostConnection::get() New Host Connection established 0xd7820, tid 657
04-04 14:34:14.429: D/libEGL(657): loaded /system/lib/egl/libGLESv1_CM_emulation.so
04-04 14:34:14.449: D/libEGL(657): loaded /system/lib/egl/libGLESv2_emulation.so
04-04 14:34:14.519: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:14.579: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:14.719: W/EGL_emulation(657): eglSurfaceAttrib not implemented
04-04 14:34:14.769: D/OpenGLRenderer(657): Enabling debug mode 0
04-04 14:34:15.049: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:15.173: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:15.579: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:15.790: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:16.030: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:16.109: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:16.549: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:16.739: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:17.029: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:17.220: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:27.099: D/AndroidRuntime(657): Shutting down VM
04-04 14:34:27.099: W/dalvikvm(657): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-04 14:34:27.219: E/AndroidRuntime(657): FATAL EXCEPTION: main
04-04 14:34:27.219: E/AndroidRuntime(657): java.lang.IllegalStateException: Could not execute method of the activity
04-04 14:34:27.219: E/AndroidRuntime(657): at android.view.View$1.onClick(View.java:3044)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.view.View.performClick(View.java:3511)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.view.View$PerformClick.run(View.java:14105)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.os.Handler.handleCallback(Handler.java:605)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.os.Handler.dispatchMessage(Handler.java:92)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.os.Looper.loop(Looper.java:137)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 14:34:27.219: E/AndroidRuntime(657): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-04 14:34:27.219: E/AndroidRuntime(657): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-04 14:34:27.219: E/AndroidRuntime(657): at dalvik.system.NativeStart.main(Native Method)
04-04 14:34:27.219: E/AndroidRuntime(657): Caused by: java.lang.reflect.InvocationTargetException
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 14:34:27.219: E/AndroidRuntime(657): at android.view.View$1.onClick(View.java:3039)
04-04 14:34:27.219: E/AndroidRuntime(657): ... 11 more
04-04 14:34:27.219: E/AndroidRuntime(657): Caused by: java.lang.NumberFormatException: Invalid double: "android.widget.EditText#40f7be40"
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.StringToReal.invalidReal(StringToReal.java:63)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.StringToReal.initialParse(StringToReal.java:114)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.StringToReal.parseDouble(StringToReal.java:263)
04-04 14:34:27.219: E/AndroidRuntime(657): at java.lang.Double.parseDouble(Double.java:295)
04-04 14:34:27.219: E/AndroidRuntime(657): at com.example.coinage.MainActivity.convert(MainActivity.java:25)
04-04 14:34:27.219: E/AndroidRuntime(657): ... 14 more
04-04 14:34:28.069: I/dalvikvm(657): threadid=3: reacting to signal 3
04-04 14:34:28.179: I/dalvikvm(657): Wrote stack traces to '/data/anr/traces.txt'
04-04 14:34:29.729: I/Process(657): Sending signal. PID: 657 SIG: 9
Method that performs Computation
public void convert(View view){
int countOf2Po = 0, countOf1Po = 0, countOf50p = 0, countOf20p = 0, countOf2p = 0, countOf1p = 0;
EditText amt = (EditText) findViewById (R.id.amount);
TextView penny = (TextView) findViewById (R.id.penny);
double amount = Double.parseDouble(amt.toString()) * 100;
while(amount >= 200){
amount = amount - 200;
countOf2Po++;
}
while(amount >= 100){
amount = amount - 100;
countOf1Po++;
}
while(amount >= 50){
amount = amount - 50;
countOf50p++;
}
while(amount >= 20){
amount = amount - 20;
countOf20p++;
}
while(amount >= 2){
amount = amount - 2;
countOf2p++;
}
if(amount % 2 != 0){
countOf1p++;
}
penny.setText("Converting " + penny + " into coins.");
penny.setVisibility(View.VISIBLE);
}
You're trying to cast the toString() value of the EditText to a double, which is not the text entered into the EditText like you expected, but the name the name of the class concatenated with the instance's hash code:
The toString method for class Object returns a string consisting of
the name of the class of which the object is an instance, the at-sign
character `#', and the unsigned hexadecimal representation of the hash
code of the object. In other words, this method returns a string equal
to the value of:
getClass().getName() + '#' + Integer.toHexString(hashCode())
What you want to do, is to retrieve the entered text using getText(), and convert that to a String:
double amount = Double.parseDouble(amt.getText().toString()) * 100;
Note that this may lead to a NumberFormatException if the input is not a proper double.

Android simple app crashing when I open it [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My main class:
package com.example.hi;
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;
import android.widget.Toast;
public class SampleLogin extends Activity {
EditText txtUserName;
EditText txtPassword;
Button btnLogin;
Button btnCancel;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtUserName=(EditText)this.findViewById(R.id.txtUname);
txtPassword=(EditText)this.findViewById(R.id.txtPwd);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
Toast.makeText(SampleLogin.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(SampleLogin.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}
}
My XML file...
<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:text="#string/User_Name: "
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtUname"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow>
<TextView
android:text="#string/Password: "
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<Button
android:text="#string/Cancel"
android:id="#+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
<Button
android:text="#string/Login"
android:id="#+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</TableRow>
</TableLayout>
So here is my code for some reason the application stops working when I open it, the "application () has stopped unexpectedly. please try again avd... " I have no idea why that is happening, help please!
I'm new to android, can someone tell me how do I get the catlog file?
About the Strings on the xml file, again I'm new to this, I was getting an error about "hard coded string" or something like that and it said I needed to add it to the strings file found in the res folder so I added the strings and then added the #string
CatLog File:
12-28 17:36:50.883: E/Zygote(33): setreuid() failed. errno: 2
12-28 17:37:00.573: E/Zygote(33): setreuid() failed. errno: 17
12-28 17:37:01.933: E/BatteryService(61): usbOnlinePath not found
12-28 17:37:01.933: E/BatteryService(61): batteryVoltagePath not found
12-28 17:37:01.933: E/BatteryService(61): batteryTemperaturePath not found
12-28 17:37:01.953: E/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
12-28 17:37:02.173: E/SensorService(61): couldn't open device for module sensors (Invalid argument)
12-28 17:37:06.682: E/System(61): Failure starting core service
12-28 17:37:06.682: E/System(61): java.lang.SecurityException
12-28 17:37:06.682: E/System(61): at android.os.BinderProxy.transact(Native Method)
12-28 17:37:06.682: E/System(61): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
12-28 17:37:06.682: E/System(61): at android.os.ServiceManager.addService(ServiceManager.java:72)
12-28 17:37:06.682: E/System(61): at com.android.server.ServerThread.run(SystemServer.java:206)
12-28 17:37:06.712: E/EventHub(61): could not get driver version for /dev/input/mouse0, Not a typewriter
12-28 17:37:06.712: E/EventHub(61): could not get driver version for /dev/input/mice, Not a typewriter
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/Effect_Tick.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressStandard.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressSpacebar.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressDelete.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressReturn.ogg
12-28 17:37:07.164: E/UsbObserver(61): java.lang.NullPointerException
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.UsbObserver.init(UsbObserver.java:131)
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.UsbObserver.<init>(UsbObserver.java:65)
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.ServerThread.run(SystemServer.java:402)
12-28 17:37:07.673: E/ThrottleService(61): Could not open GPS configuration file /etc/gps.conf
12-28 17:37:08.392: E/logwrapper(135): executing /system/bin/tc failed: No such file or directory
12-28 17:37:08.392: E/logwrapper(136): executing /system/bin/tc failed: No such file or directory
12-28 17:37:08.432: E/logwrapper(138): executing /system/bin/tc failed: No such file or directory
12-28 17:37:35.198: E/AndroidRuntime(335): FATAL EXCEPTION: main
12-28 17:37:35.198: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hi/com.example.hi.MainActivity}: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:507)
12-28 17:37:35.198: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-28 17:37:35.198: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-28 17:37:35.198: E/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
12-28 17:37:35.198: E/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:37:35.198: E/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-28 17:37:35.198: E/AndroidRuntime(335): ... 11 more
12-28 17:38:05.517: E/AndroidRuntime(344): FATAL EXCEPTION: main
12-28 17:38:05.517: E/AndroidRuntime(344): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hi/com.example.hi.MainActivity}: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.os.Looper.loop(Looper.java:123)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.reflect.Method.invoke(Method.java:507)
12-28 17:38:05.517: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-28 17:38:05.517: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-28 17:38:05.517: E/AndroidRuntime(344): at dalvik.system.NativeStart.main(Native Method)
12-28 17:38:05.517: E/AndroidRuntime(344): Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:38:05.517: E/AndroidRuntime(344): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-28 17:38:05.517: E/AndroidRuntime(344): ... 11 more
It doesn't crash anymore but I can't type anything!! I changed something on the xml file about typing because it was giving me a problem
android:inputType="textPassword|number"
I think it was this but when I try to type something it does nothing!
Is this supposed to work?
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtUname"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
From your LogCat:
Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
This means that you probably changed your class name to SampleLogin from MainActivity but forgot to update your manifest.
Update the manifest to look like this:
<activity
android:name=".SampleLogin"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
(You will also need to address android:text="#string/User_Name: " and android:text="#string/Password: " as I mentioned in the comments before you can compile your app again.)
You should see the LogCat to know what is the error exactly.
The only thing I can spot in your code is that you are initilizing the btnLogin twice and missing the initialization of btnCancel. This would not be the source of the error unless you are using btnCancel object somewhere.
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
If you can post the error from LogCat, it will be easier to help.
Edit
In your layout XML file you have something looks odd
android:text="#string/Password: "
android:id="#+id/TextView01"
There are not appropriate name for resources it should be all small letters with only underscore as word separator if needed.

Update old android project

I am following this tutorial and I can make it work just fine, but when I try to update the UI to fit the new Holo.Light in android 4.2 the app crashes at launch, and I don't know why.
I have been searching for a way to update the UI but I could not get it to work.
I wonder if anybody could help me? tell me how? Give me a link that you know would work?
or even do it yourself?
i get this error log:
11-20 09:50:39.523: I/dalvikvm(1460): threadid=3: reacting to signal 3
11-20 09:50:39.682: I/dalvikvm(1460): Wrote stack traces to '/data/anr/traces.txt'
11-20 09:50:39.892: I/dalvikvm(1460): threadid=3: reacting to signal 3
11-20 09:50:40.003: I/dalvikvm(1460): Wrote stack traces to '/data/anr/traces.txt'
11-20 09:50:40.102: D/AndroidRuntime(1460): Shutting down VM
11-20 09:50:40.102: W/dalvikvm(1460): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
11-20 09:50:40.132: E/AndroidRuntime(1460): FATAL EXCEPTION: main
11-20 09:50:40.132: E/AndroidRuntime(1460): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: android.os.NetworkOnMainThreadException
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.os.Looper.loop(Looper.java:137)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-20 09:50:40.132: E/AndroidRuntime(1460): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 09:50:40.132: E/AndroidRuntime(1460): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 09:50:40.132: E/AndroidRuntime(1460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-20 09:50:40.132: E/AndroidRuntime(1460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-20 09:50:40.132: E/AndroidRuntime(1460): at dalvik.system.NativeStart.main(Native Method)
11-20 09:50:40.132: E/AndroidRuntime(1460): Caused by: android.os.NetworkOnMainThreadException
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
11-20 09:50:40.132: E/AndroidRuntime(1460): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
11-20 09:50:40.132: E/AndroidRuntime(1460): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
11-20 09:50:40.132: E/AndroidRuntime(1460): at java.net.InetAddress.getAllByName(InetAddress.java:220)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-20 09:50:40.132: E/AndroidRuntime(1460): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
11-20 09:50:40.132: E/AndroidRuntime(1460): at com.androidhive.jsonparsing.JSONParser.getJSONFromUrl(JSONParser.java:38)
11-20 09:50:40.132: E/AndroidRuntime(1460): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:53)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.Activity.performCreate(Activity.java:4465)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-20 09:50:40.132: E/AndroidRuntime(1460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-20 09:50:40.132: E/AndroidRuntime(1460): ... 11 more
11-20 09:50:40.392: I/dalvikvm(1460): threadid=3: reacting to signal 3
11-20 09:50:40.412: I/dalvikvm(1460): Wrote stack traces to '/data/anr/traces.txt'
11-20 09:50:40.791: I/dalvikvm(1460): threadid=3: reacting to signal 3
11-20 09:50:40.962: I/dalvikvm(1460): Wrote stack traces to '/data/anr/traces.txt'
You are making a network call on the main thread. This is not allowed on Android 4.2, and is a really bad idea on earlier versions which do permit this. I have blogged about various mechanisms for moving network and other heavy calls off the main thread at http://blog.stylingandroid.com/archives/833.
Without seeing your code, I cannot begin to suggest which approach is the right one for you to use, but hopefully the information in my articles will help you in deciding upon the correct approach.
There are two Solution of this Problem.
1) Don't write network call in Main UIThread, Use Async Task for that.
2) Write below code into your MainActivity file after setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
And below import statement into your java file.
import android.os.StrictMode;
and see below link for more information.
Twitter connect error

android parcel read exception

this is the follow up question to this one
I get the following stack logcat parcel read ecception why do I get this
10-09 10:27:27.993: I/dalvikvm(825): threadid=3: reacting to signal 3
10-09 10:27:28.093: I/dalvikvm(825): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:27:28.422: D/gralloc_goldfish(825): Emulator without GPU emulation detected.
10-09 10:28:45.692: W/ActivityThread(872): Application com.example.sms is waiting for the debugger on port 8100...
10-09 10:28:45.793: I/System.out(872): Sending WAIT chunk
10-09 10:28:45.813: I/dalvikvm(872): Debugger is active
10-09 10:28:45.833: I/System.out(872): Debugger has connected
10-09 10:28:45.853: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.063: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.263: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.273: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:46.312: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:46.462: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.662: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.783: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:46.793: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:46.863: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.072: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.263: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:47.293: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.293: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:47.492: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.692: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.763: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:47.773: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:47.893: I/System.out(872): waiting for debugger to settle...
10-09 10:28:48.100: I/System.out(872): debugger has settled (1441)
10-09 10:28:48.273: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:48.402: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:48.773: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:48.813: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:49.213: D/gralloc_goldfish(872): Emulator without GPU emulation detected.
10-09 10:28:49.282: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:49.322: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:00.063: D/AndroidRuntime(872): Shutting down VM
10-09 10:29:00.063: W/dalvikvm(872): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:29:00.203: E/AndroidRuntime(872): FATAL EXCEPTION: main
10-09 10:29:00.203: E/AndroidRuntime(872): java.lang.NullPointerException
10-09 10:29:00.203: E/AndroidRuntime(872): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:59)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.view.View.performClick(View.java:3511)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.os.Looper.loop(Looper.java:137)
10-09 10:29:00.203: E/AndroidRuntime(872): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:29:00.203: E/AndroidRuntime(872): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:29:00.203: E/AndroidRuntime(872): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:29:00.203: E/AndroidRuntime(872): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:29:00.203: E/AndroidRuntime(872): at dalvik.system.NativeStart.main(Native Method)
10-09 10:29:00.803: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:29:00.823: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:48.632: I/dalvikvm(920): threadid=3: reacting to signal 3
10-09 10:29:48.793: I/dalvikvm(920): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:49.133: I/dalvikvm(920): threadid=3: reacting to signal 3
10-09 10:29:49.173: I/dalvikvm(920): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:49.203: D/gralloc_goldfish(920): Emulator without GPU emulation detected.
10-09 10:30:34.003: W/ActivityThread(960): Application com.example.sms is waiting for the debugger on port 8100...
10-09 10:30:34.093: I/System.out(960): Sending WAIT chunk
10-09 10:30:34.103: I/dalvikvm(960): Debugger is active
10-09 10:30:34.113: I/System.out(960): Debugger has connected
10-09 10:30:34.163: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.362: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.432: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:34.442: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:34.562: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.763: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.923: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:34.933: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:34.963: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.170: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.371: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.442: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:35.462: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:35.573: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.773: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.953: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.013: I/System.out(960): waiting for debugger to settle...
10-09 10:30:36.013: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:36.215: I/System.out(960): debugger has settled (1432)
10-09 10:30:36.452: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.582: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:36.953: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.983: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:37.462: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:37.472: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:37.502: D/gralloc_goldfish(960): Emulator without GPU emulation detected.
10-09 10:31:08.195: D/AndroidRuntime(960): Shutting down VM
10-09 10:31:08.195: W/dalvikvm(960): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:31:08.292: E/AndroidRuntime(960): FATAL EXCEPTION: main
10-09 10:31:08.292: E/AndroidRuntime(960): java.lang.NullPointerException
10-09 10:31:08.292: E/AndroidRuntime(960): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.view.View.performClick(View.java:3511)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.os.Looper.loop(Looper.java:137)
10-09 10:31:08.292: E/AndroidRuntime(960): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:31:08.292: E/AndroidRuntime(960): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:31:08.292: E/AndroidRuntime(960): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:31:08.292: E/AndroidRuntime(960): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:31:08.292: E/AndroidRuntime(960): at dalvik.system.NativeStart.main(Native Method)
10-09 10:31:08.913: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:31:08.923: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:31:11.983: I/Process(960): Sending signal. PID: 960 SIG: 9
10-09 10:31:28.392: I/dalvikvm(1008): threadid=3: reacting to signal 3
10-09 10:31:28.492: I/dalvikvm(1008): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:31:28.843: D/gralloc_goldfish(1008): Emulator without GPU emulation detected.
10-09 10:31:32.713: D/AndroidRuntime(1008): Shutting down VM
10-09 10:31:32.713: W/dalvikvm(1008): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:31:32.803: E/AndroidRuntime(1008): FATAL EXCEPTION: main
10-09 10:31:32.803: E/AndroidRuntime(1008): java.lang.NullPointerException
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.view.View.performClick(View.java:3511)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.os.Looper.loop(Looper.java:137)
10-09 10:31:32.803: E/AndroidRuntime(1008): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:31:32.803: E/AndroidRuntime(1008): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:31:32.803: E/AndroidRuntime(1008): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:31:32.803: E/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:31:32.803: E/AndroidRuntime(1008): at dalvik.system.NativeStart.main(Native Method)
10-09 10:31:33.392: I/dalvikvm(1008): threadid=3: reacting to signal 3
10-09 10:31:33.402: I/dalvikvm(1008): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:32:10.452: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:32:10.523: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:32:10.923: D/gralloc_goldfish(1055): Emulator without GPU emulation detected.
10-09 10:32:10.953: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:32:10.973: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:10.863: D/AndroidRuntime(1055): Shutting down VM
10-09 10:35:10.863: W/dalvikvm(1055): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:35:10.883: E/AndroidRuntime(1055): FATAL EXCEPTION: main
10-09 10:35:10.883: E/AndroidRuntime(1055): java.lang.NullPointerException
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.view.View.performClick(View.java:3511)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.os.Looper.loop(Looper.java:137)
10-09 10:35:10.883: E/AndroidRuntime(1055): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:35:10.883: E/AndroidRuntime(1055): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:35:10.883: E/AndroidRuntime(1055): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:35:10.883: E/AndroidRuntime(1055): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:35:10.883: E/AndroidRuntime(1055): at dalvik.system.NativeStart.main(Native Method)
10-09 10:35:11.453: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:35:11.473: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:50.673: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:35:50.803: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:51.112: D/gralloc_goldfish(1104): Emulator without GPU emulation detected.
10-09 10:35:51.142: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:35:51.182: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:12.383: D/AndroidRuntime(1104): Shutting down VM
10-09 10:37:12.383: W/dalvikvm(1104): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:37:12.403: E/AndroidRuntime(1104): FATAL EXCEPTION: main
10-09 10:37:12.403: E/AndroidRuntime(1104): java.lang.NullPointerException
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.view.View.performClick(View.java:3511)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.os.Looper.loop(Looper.java:137)
10-09 10:37:12.403: E/AndroidRuntime(1104): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:37:12.403: E/AndroidRuntime(1104): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:37:12.403: E/AndroidRuntime(1104): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:37:12.403: E/AndroidRuntime(1104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:37:12.403: E/AndroidRuntime(1104): at dalvik.system.NativeStart.main(Native Method)
10-09 10:37:12.992: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:37:13.012: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:24.783: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:24.882: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:25.283: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:25.303: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:25.503: D/gralloc_goldfish(1169): Emulator without GPU emulation detected.
10-09 10:37:34.952: W/IInputConnectionWrapper(1169): showStatusIcon on inactive InputConnection
10-09 10:37:45.533: D/AndroidRuntime(1169): Shutting down VM
10-09 10:37:45.533: W/dalvikvm(1169): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:37:45.563: E/AndroidRuntime(1169): FATAL EXCEPTION: main
10-09 10:37:45.563: E/AndroidRuntime(1169): java.lang.NullPointerException
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.view.View.performClick(View.java:3511)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.view.View$PerformClick.run(View.java:14105)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.os.Looper.loop(Looper.java:137)
10-09 10:37:45.563: E/AndroidRuntime(1169): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:37:45.563: E/AndroidRuntime(1169): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:37:45.563: E/AndroidRuntime(1169): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:37:45.563: E/AndroidRuntime(1169): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:37:45.563: E/AndroidRuntime(1169): at dalvik.system.NativeStart.main(Native Method)
10-09 10:37:46.122: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:46.142: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'
smsactivity
public class SendSMSActivity extends Activity {
Button btnSendSMS;
EditText txtPhoneNo;
EditText txtMessage;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
txtMessage = (EditText) findViewById(R.id.txtMessage);
btnSendSMS.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String phoneNo = txtPhoneNo.getText().toString();
String message = txtMessage.getText().toString();
if (phoneNo.length() > 0 && message.length() > 0)
{
TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
switch (simState) {
case TelephonyManager.SIM_STATE_ABSENT:
Toast.makeText(getBaseContext(), "No Sim Card found",
Toast.LENGTH_SHORT).show();
break;
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
// do something
break;
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_READY:
sendSMS(phoneNo, message); // method to send message
break;
case TelephonyManager.SIM_STATE_UNKNOWN:
// do something
break;
}
} else
Toast.makeText(getBaseContext(),
"Please enter both phone number and message.",
Toast.LENGTH_SHORT).show();
}
private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(
SendSMSActivity.this, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(
SendSMSActivity.this, 0, new Intent(DELIVERED), 0);
// ---when the SMS has been sent---final String string =
// "deprecation";
registerReceiver(new BroadcastReceiver() {
#Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(SendSMSActivity.this, "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(SendSMSActivity.this,
"Generic failure", Toast.LENGTH_SHORT)
.show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(SendSMSActivity.this, "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(SendSMSActivity.this, "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));
// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
#Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(SendSMSActivity.this,
"SMS delivered", Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(SendSMSActivity.this,
"SMS not delivered", Toast.LENGTH_SHORT)
.show();
break;
}
}
}, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI,
deliveredPI);
}
});
}
}

How to display an image in an image button with shared preferences?

In one of my activities you can click on an image button and a dialog opens up to ask you to open up the Gallery. Once opened up you can click on one of those images in your gallery.
What I want that the clicked image is set as the image of the image button. This image should stay there even when the user kills the app (when he opens up the app again the chosen image should still be there).
I chose to do all this work with the shared preferences but can't get it working. I get an error when I click on an image in the gallery. Any suggestions??
UPDATE: The error I receive is:
Unfortunately, the process com.myname.android has stopped
Here is my code, beginning with the onActivityResult:
private String selectedImagePath;
private String mFileName;
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == PICK_FROM_FILE) {
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Log.v("IMAGE PATH====>>>> ",selectedImagePath);
}
storePath();
retrievePath();
convertPathToImage();
}
}
private void storePath() {
final SharedPreferences sPreference = getSharedPreferences(
"pref_key", MODE_PRIVATE);
final Editor spEditor = sPreference.edit();
spEditor.putString("img_path", mFileName);
spEditor.commit();
}
private void retrievePath() {
final SharedPreferences sharedPreference = getSharedPreferences(
"pref_key", MODE_PRIVATE);
if (sharedPreference.contains("img_path")) {
mFileName = sharedPreference.getString("img_path",
null);
}
}
private void convertPathToImage() {
File imgFile = new File(mFileName);
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageButton myImage = (ImageButton) findViewById(R.id.image);
myImage.setImageBitmap(myBitmap);
}
}
And here is the LogCat:
05-30 15:27:14.567: D/dalvikvm(634): GC_CONCURRENT freed 1K, 3% free 11478K/11783K, paused 5ms+4ms
05-30 15:27:14.597: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:14.617: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:14.926: D/gralloc_goldfish(634): Emulator without GPU emulation detected.
05-30 15:27:26.767: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:26.877: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:30.616: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:30.626: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:32.086: W/IInputConnectionWrapper(634): showStatusIcon on inactive InputConnection
05-30 15:27:33.366: E/ActivityThread(634): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1#4155da80 that was originally registered here. Are you missing a call to unregisterReceiver()?
05-30 15:27:33.366: E/ActivityThread(634): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1#4155da80 that was originally registered here. Are you missing a call to unregisterReceiver()?
05-30 15:27:33.366: E/ActivityThread(634): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1043)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1030)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1024)
05-30 15:27:33.366: E/ActivityThread(634): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341)
05-30 15:27:33.366: E/ActivityThread(634): at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:65)
05-30 15:27:33.366: E/ActivityThread(634): at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:99)
05-30 15:27:33.366: E/ActivityThread(634): at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:53)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.Activity.performCreate(Activity.java:4465)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-30 15:27:33.366: E/ActivityThread(634): at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 15:27:33.366: E/ActivityThread(634): at android.os.Looper.loop(Looper.java:137)
05-30 15:27:33.366: E/ActivityThread(634): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-30 15:27:33.366: E/ActivityThread(634): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 15:27:33.366: E/ActivityThread(634): at java.lang.reflect.Method.invoke(Method.java:511)
05-30 15:27:33.366: E/ActivityThread(634): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-30 15:27:33.366: E/ActivityThread(634): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-30 15:27:33.366: E/ActivityThread(634): at dalvik.system.NativeStart.main(Native Method)
05-30 15:27:35.987: V/IMAGE PATH====>>>>(634): /mnt/sdcard/Mercedes_SLS_AMG.jpg
05-30 15:27:36.176: D/AndroidRuntime(634): Shutting down VM
05-30 15:27:36.176: W/dalvikvm(634): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-30 15:27:36.206: E/AndroidRuntime(634): FATAL EXCEPTION: main
05-30 15:27:36.206: E/AndroidRuntime(634): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { dat=content://media/external/images/media/20 }} to activity {com.xyz.android.taskreminder/com.xyz.android.taskreminder.ReminderEditActivity}: java.lang.NullPointerException
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread.access$1100(ActivityThread.java:123)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.os.Looper.loop(Looper.java:137)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-30 15:27:36.206: E/AndroidRuntime(634): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 15:27:36.206: E/AndroidRuntime(634): at java.lang.reflect.Method.invoke(Method.java:511)
05-30 15:27:36.206: E/AndroidRuntime(634): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-30 15:27:36.206: E/AndroidRuntime(634): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-30 15:27:36.206: E/AndroidRuntime(634): at dalvik.system.NativeStart.main(Native Method)
05-30 15:27:36.206: E/AndroidRuntime(634): Caused by: java.lang.NullPointerException
05-30 15:27:36.206: E/AndroidRuntime(634): at java.io.File.fixSlashes(File.java:185)
05-30 15:27:36.206: E/AndroidRuntime(634): at java.io.File.<init>(File.java:134)
05-30 15:27:36.206: E/AndroidRuntime(634): at com.xyz.android.taskreminder.ReminderEditActivity.convertPathToImage(ReminderEditActivity.java:249)
05-30 15:27:36.206: E/AndroidRuntime(634): at com.xyz.android.taskreminder.ReminderEditActivity.onActivityResult(ReminderEditActivity.java:227)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.Activity.dispatchActivityResult(Activity.java:4649)
05-30 15:27:36.206: E/AndroidRuntime(634): at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
05-30 15:27:36.206: E/AndroidRuntime(634): ... 11 more
05-30 15:27:36.376: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:36.396: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:36.787: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:36.847: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:37.386: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:37.406: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:37.887: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:37.947: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:38.396: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:38.416: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:38.897: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:38.927: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:39.406: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:39.426: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:39.917: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:39.927: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:40.426: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:40.446: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:40.917: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:40.947: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:41.426: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:41.447: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:41.937: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:41.977: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:42.446: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:42.467: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:42.937: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:42.956: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:43.446: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:43.467: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:43.947: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:43.976: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:44.456: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:44.477: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:44.966: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:44.986: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
05-30 15:27:45.466: I/dalvikvm(634): threadid=3: reacting to signal 3
05-30 15:27:45.487: I/dalvikvm(634): Wrote stack traces to '/data/anr/traces.txt'
Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1#4155da80 that was originally registered here. Are you missing a call to unregisterReceiver()?
This is probably a bug in Android. See http://code.google.com/p/android/issues/detail?id=29399. It shouldn't effect the app though which should still be able to get a result back from the gallery.
05-30 15:27:36.206: E/AndroidRuntime(634): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { dat=content://media/external/images/media/20 }} to activity {com.ndroidstudios.android.taskreminder/com.ndroidstudios.android.taskreminder.ReminderEditActivity}: java.lang.NullPointerException
...
05-30 15:27:36.206: E/AndroidRuntime(634): Caused by: java.lang.NullPointerException
This is the problem. mFileName is null when you try to use it to create a new File. In retrievePath, when you try to pull "img_path" out of your preferences the default value is null, so I'm guessing it's getting set to null there. Check in the debugger to make sure mFileName is getting set to a valid String from your preferences.

Categories

Resources