How to optimize app for many API version? - android

I'm development app in android and use my device with API version 17 to running the app, but when I use device with API 10, the app close when start and this is the log. What mean these errors?
E/AndroidRuntime(2336): FATAL EXCEPTION: main
E/AndroidRuntime(2336): java.lang.NullPointerException
E/AndroidRuntime(2336): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:263)
E/AndroidRuntime(2336): at java.lang.Double.parseDouble(Double.java:318)
E/AndroidRuntime(2336): at com.gestionderiesgos.sismosecuador.SitesAdapter.getView(SitesAdapter.java:81)
E/AndroidRuntime(2336): at android.widget.AbsListView.obtainView(AbsListView.java:1554)
E/AndroidRuntime(2336): at android.widget.ListView.makeAndAddView(ListView.java:1793)
E/AndroidRuntime(2336): at android.widget.ListView.fillDown(ListView.java:718)
E/AndroidRuntime(2336): at android.widget.ListView.fillFromTop(ListView.java:775)
E/AndroidRuntime(2336): at android.widget.ListView.layoutChildren(ListView.java:1646)
E/AndroidRuntime(2336): at android.widget.AbsListView.onLayout(AbsListView.java:1384)
E/AndroidRuntime(2336): at android.view.View.layout(View.java:7228)
E/AndroidRuntime(2336): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
E/AndroidRuntime(2336): at android.view.View.layout(View.java:7228)
E/AndroidRuntime(2336): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime(2336): at android.view.View.layout(View.java:7228)
E/AndroidRuntime(2336): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
E/AndroidRuntime(2336): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
E/AndroidRuntime(2336): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
E/AndroidRuntime(2336): at android.view.View.layout(View.java:7228)
E/AndroidRuntime(2336): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime(2336): at android.view.View.layout(View.java:7228)
E/AndroidRuntime(2336): at android.view.ViewRoot.performTraversals(ViewRoot.java:1145)
E/AndroidRuntime(2336): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
E/AndroidRuntime(2336): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(2336): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(2336): at android.app.ActivityThread.main(ActivityThread.java:3687)
E/AndroidRuntime(2336): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(2336): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(2336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
E/AndroidRuntime(2336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/AndroidRuntime(2336): at dalvik.system.NativeStart.main(Native Method)

You have to setup if conditions in your code to prevent null errors by lower API versions - for example:
if (Build.VERSION.SDK_INT < 11) {
//code
} else {
//code
}

Related

Android 4.0 Issue with google plus login

I have google plus login working fine on devices > 4.1 but some devices cause a crash on 4.0
My best guess is that there is a issue(or it is outdated) with google play services installed on the device.
This is the error I get:
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.frankly/me.frankly.view.activity.NewLoginActivity}: android.view.InflateException: Binary XML file line #103: Error inflating class com.google.android.gms.common.SignInButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2077)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: android.view.InflateException: Binary XML file line #103: Error inflating class com.google.android.gms.common.SignInButton
at android.view.LayoutInflater.createView(LayoutInflater.java:608)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.inflate(LayoutInflater.java:491)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
at android.app.Activity.setContentView(Activity.java:1837)
at me.frankly.view.activity.NewLoginActivity.onCreate(NewLoginActivity.java:112)
at android.app.Activity.performCreate(Activity.java:4479)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:588)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.inflate(LayoutInflater.java:491)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
at android.app.Activity.setContentView(Activity.java:1837)
at me.frankly.view.activity.NewLoginActivity.onCreate(NewLoginActivity.java:112)
at android.app.Activity.performCreate(Activity.java:4479)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.R$drawable
at com.google.android.gms.common.internal.q.b()
at com.google.android.gms.common.internal.q.a()
at com.google.android.gms.common.SignInButton.a()
at com.google.android.gms.common.SignInButton.G()
at com.google.android.gms.common.SignInButton.setStyle()
at com.google.android.gms.common.SignInButton.<init>()
at com.google.android.gms.common.SignInButton.<init>()
at java.lang.reflect.Constructor.constructNative(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:588)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:744)
at android.view.LayoutInflater.inflate(LayoutInflater.java:491)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
at android.app.Activity.setContentView(Activity.java:1837)
at me.frankly.view.activity.NewLoginActivity.onCreate(NewLoginActivity.java:112)
at android.app.Activity.performCreate(Activity.java:4479)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(NativeStart.java)
Going through your stack traces I noticed
Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.R$drawable
That leads me to assume that you added the jar for the Play Services SDK but didn't add the Android library project and that is why it could not be found. It may also be possibility that you may be using an outdated version of the Play Service SDK.
I suggest viewing CommonsWare solution by clicking here.

Unable to start activity NullPointerException-onActivityCreated

My App crash rarely
i want to get off this bug for ever.
this is the log that users Report
i tried so long on this but nothing helps
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.Master_}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.access$600(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4787)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.xxx.xxx.HomeFragment.onActivityCreated(HomeFragment.java:140)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1508)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:958)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1097)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1895)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:566)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
... 11 more

Store/Save & Retrieve to/from SharedPreference Failure

I've been having so much problem with this Live Wallpaper.
I have read alot online about these, and I thought I understood and got them.
When I tried to apply them to this live wallpaper, everything has been going very rough.
I've spent all day and night :-(
Could you someone please help me out?
My goal is to store the new password from edittextpreference to the
Sharedpreference, and then retrieve this password to compared with the login
password to if they are matched.
For example,
I have 2 edittextpreferences:
1) is for create new password which will be saved to the SharedPreference
2) is for login password.
The users will be granted the access when the login password is matched with the
one in the SharedPreference.
Please help me out,
I would be appreciated for your help.
prefs.java Code:
#SuppressWarnings("deprecation")
#Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
// TODO Auto-generated method stub
{
}
}
{
SharedPreferences mlogin_password = this.getSharedPreferences("data_storage", MODE_PRIVATE);
Editor login_password = mlogin_password.edit();
login_password.putString("login", "login_pw2");
login_password.commit();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Context);
String s = sp.getString("login", null);
Sorry for 10000000 of error codes :-(
Logcat:
at android.util.Log.println_native(Native Method)
at android.util.Log.v(Log.java:117)
at rare_war.weapons.prefs.<init>(prefs.java:60)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:62)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:64)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:66)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:63)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:65)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:75)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:74)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:374)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at rare_war.weapons.prefs.<init>(prefs.java:75)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at rare_war.weapons.prefs.<init>(prefs.java:68)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1130)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
... 11 more
My goal is to store the new password from edittextpreference to the
Sharedpreference...
Not a good idea. You shouldn't store passwords on SharedPreferences
I would suggest using a different approach like storing the encrypted password on a server and then check what the user entered against it.
Please, also make sure you read the Android guide on SharedPreferences
Hi you are saving password on sharedPreference named 'data_storage' and retrieving from default sharedPreference thats why you are not getting saved password.Try to save and retrieve preference value from same sharedPreference.
Why don't you use getSharedPreferences for the key "data_storage" and not for getDefaultSharedPreferences, in other words, Context? I'm not really sure about it, but you should try.
The mechanism works as follows: you save the key under a string name "date_storage" then you retrieve they key. In both cases you need to get the SharedPreferences with the line:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Context);
After that use the "sp.get()" methods to get the required value for the saved string key ("data_storage").

Set header to listview from layout

everybody!
I got such situation: I have a layout with some views and a listView. A question is: is it possible to take those views (from the layout where listview is situated) and set them as a header to this listview?
By now I tried:
LinearLayout header = (LinearLayout)getView().findViewById(R.id.header);
listView.addHeaderView(header, null, true);
This gives me an error:
ERROR/AndroidRuntime(18913): FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
at android.widget.ListView.clearRecycledState(ListView.java:553)
at android.widget.ListView.resetList(ListView.java:539)
at android.widget.ListView.layoutChildren(ListView.java:1477)
at android.widget.AbsListView.onLayout(AbsListView.java:1407)
at android.view.View.layout(View.java:7314)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
at android.view.View.layout(View.java:7314)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1180)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1900)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)

application has stopped unexpectedly

When I run my android application it gives an error "The application has stopped working,please try again". Please help me to solve this problem. i have created a method which gets called when the button gets clicked. When I include the code for calling another class in this method it shows the above error & when I remove that code it neither shows the error nor goes ahead when listview etc. gets clicked. Can you please check my code and help me please.
CODE:
public void myClickHandler(View view)
{
//Toast.makeText(this, "yesss",Toast.LENGTH_LONG).show();
setContentView(R.layout.screen1);
ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, city);
ListView FirstProjectActivity = (ListView) findViewById(R.id.mylist1);
FirstProjectActivity.setAdapter(adapter);
Intent myIntent = new Intent(FirstProjectActivity.this,
City.class);
FirstProjectActivity.this.startActivity(myIntent);
//startActivity(new Intent(FirstProjectActivity.this, City.class));
}
LOGCAT is as follows:
03-02 18:56:28.136: D/AndroidRuntime(316): Shutting down VM
03-02 18:56:28.136: W/dalvikvm(316): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 18:56:28.226: E/AndroidRuntime(316): FATAL EXCEPTION: main
03-02 18:56:28.226: E/AndroidRuntime(316): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Looper.loop(Looper.java:123)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 18:56:28.226: E/AndroidRuntime(316): at dalvik.system.NativeStart.main(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): Caused by: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 18:56:28.226: E/AndroidRuntime(316): ... 11 more
03-02 18:56:35.396: I/Process(316): Sending signal. PID: 316 SIG: 9
03-02 19:02:51.836: D/AndroidRuntime(351): Shutting down VM
03-02 19:02:51.836: W/dalvikvm(351): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 19:02:51.866: E/AndroidRuntime(351): FATAL EXCEPTION: main
03-02 19:02:51.866: E/AndroidRuntime(351): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Looper.loop(Looper.java:123)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 19:02:51.866: E/AndroidRuntime(351): at dalvik.system.NativeStart.main(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): Caused by: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 19:02:51.866: E/AndroidRuntime(351): ... 11 more
03-02 19:03:03.647: I/Process(351): Sending signal. PID: 351 SIG: 9
03-02 20:11:17.722: W/KeyCharacterMap(379): No keyboard for id 0
03-02 20:11:17.926: W/KeyCharacterMap(379): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-02 20:11:28.441: D/dalvikvm(379): GC_EXPLICIT freed 3121 objects / 172672 bytes in 1696ms
03-03 01:03:02.696: W/KeyCharacterMap(406): No keyboard for id 0
03-03 01:03:02.696: W/KeyCharacterMap(406): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-03 01:03:08.566: D/dalvikvm(406): GC_EXPLICIT freed 2874 objects / 162408 bytes in 192ms
03-03 01:33:06.566: D/AndroidRuntime(432): Shutting down VM
03-03 01:33:06.566: W/dalvikvm(432): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:33:06.726: E/AndroidRuntime(432): FATAL EXCEPTION: main
03-03 01:33:06.726: E/AndroidRuntime(432): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2072)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View.performClick(View.java:2408)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Looper.loop(Looper.java:123)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:33:06.726: E/AndroidRuntime(432): at dalvik.system.NativeStart.main(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:33:06.726: E/AndroidRuntime(432): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:69)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2067)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 11 more
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 15 more
03-03 01:33:08.956: I/Process(432): Sending signal. PID: 432 SIG: 9
03-03 01:34:05.387: D/AndroidRuntime(460): Shutting down VM
03-03 01:34:05.387: W/dalvikvm(460): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:34:05.417: E/AndroidRuntime(460): FATAL EXCEPTION: main
03-03 01:34:05.417: E/AndroidRuntime(460): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2072)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View.performClick(View.java:2408)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Looper.loop(Looper.java:123)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:34:05.417: E/AndroidRuntime(460): at dalvik.system.NativeStart.main(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:34:05.417: E/AndroidRuntime(460): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2067)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 11 more
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 15 more
03-03 01:34:11.016: I/Process(460): Sending signal. PID: 460 SIG: 9
03-03 01:35:33.547: D/AndroidRuntime(490): Shutting down VM
03-03 01:35:33.557: W/dalvikvm(490): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:35:33.577: E/AndroidRuntime(490): FATAL EXCEPTION: main
03-03 01:35:33.577: E/AndroidRuntime(490): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2072)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View.performClick(View.java:2408)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Looper.loop(Looper.java:123)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:35:33.577: E/AndroidRuntime(490): at dalvik.system.NativeStart.main(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:35:33.577: E/AndroidRuntime(490): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2067)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 11 more
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 15 more
03-03 01:35:39.176: I/Process(490): Sending signal. PID: 490 SIG: 9
03-03 01:36:06.947: D/AndroidRuntime(517): Shutting down VM
03-03 01:36:06.947: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:36:06.967: E/AndroidRuntime(517): FATAL EXCEPTION: main
03-03 01:36:06.967: E/AndroidRuntime(517): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2072)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View.performClick(View.java:2408)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:123)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:36:06.967: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:36:06.967: E/AndroidRuntime(517): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2067)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 11 more
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 15 more
03-03 01:36:13.306: I/Process(517): Sending signal. PID: 517 SIG: 9
When you want to detect if you click on an item you need to implement the onItemClickedListener i will give you an example below like i would do it:
listView.setOnItemClickListener(new MyOnitemClickListener());
//no i make my own class that impelemnts the onitemclicklistener
public class MyOnitemClickListener implements OnItemClickListener {
private int position = 0;
public void onItemClick(AdapterView<?> parent, View view, int pos,
long lat) {
// clicked on parent.getid()
if (parent.getId() == R.id.listView) {
//do something
}
}
}
after a crash, try looking for the first couple of red lines the LOGCAT spews to you as they usually explain what happened.
the following line :
java.lang.NullPointerException
(in line 5) showed up on you log, it usually means your trying to use an uninitialized object.
refer to:
What is a NullPointerException, and how do I fix it?

Categories

Resources