Having troubles with File.contains(file) and File.add(file) - android

I try to code an Android App.
The code below should add the parent of a file to my list, but only if the parent is not already in the list.
files[] is an array of Files in a directory
imageFolders is created like this:
private List <File> imageFolders;
private String [] extensions;
File [] files = folder.listFiles();
extensions = new String [] {".png",".jpg",".jpeg"};
//important part:
if(files[i].toString().contains(extensions[b]))
{
System.out.println("Checkpoint 1");
if(!imageFolders.contains((File)files[i].getParentFile()))
{
System.out.println("Checkpoint 2");
imageFolders.add((File)files[i].getParentFile());
}
}
And then the log gives me this and the app shuts down:
09-26 08:33:55.580: I/System.out(1753): /system/lib/hw/camera.goldfish.jpeg.so //gives me the file[i]
09-26 08:33:55.580: I/System.out(1753): Checkpoint 1
09-26 08:33:55.590: D/AndroidRuntime(1753): Shutting down VM
09-26 08:33:55.610: W/dalvikvm(1753): threadid=1: thread exiting with uncaught exception
(group=0xb1a87ba8)
09-26 08:33:55.650: E/AndroidRuntime(1753): FATAL EXCEPTION: main
09-26 08:33:55.650: E/AndroidRuntime(1753): Process: de.FriedSloth.fastphotomanager, PID: 1753
09-26 08:33:55.650: E/AndroidRuntime(1753): java.lang.RuntimeException: Unable to start activity
ComponentInfo{de.FriedSloth.fastphotomanager/de.FriedSloth.fastphotomanager.Side2}: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Looper.loop(Looper.java:136)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invokeNative(Native
Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invoke(Method.java:515)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-26 08:33:55.650: E/AndroidRuntime(1753): at dalvik.system.NativeStart.main(Native Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): Caused by: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:61)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.onCreate(Side2.java:32)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Activity.performCreate(Activity.java:5231)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
09-26 08:33:55.650: E/AndroidRuntime(1753): ... 11 more

Related

Animated toggle button Error inflating class android.widget.ToggleButton

im trying to make a toggle button with animation i use a toggle button and 4 XML to do so :
here is my main activity which toggle button is in it :
<ToggleButton
android:id="#+id/toggle"
android:layout_width="144dp"
android:layout_height="144dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/btn_toggle_bg"
android:checked="true"
android:onClick="OnPressToggle" />
and here is my btn_toggle_bg . xml which had background values :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+android:id/background" android:drawable="#android:color/transparent" />
<item android:id="#+android:id/toggle" android:drawable="#drawable/btn_toggle" />
</layer-list>
</LinearLayout>
and here is my btn_toggle . xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="#drawable/btn_switch_on" />
<item android:state_checked="false" android:drawable="#drawable/btn_switch_off" />
</selector>
here is the new log cat
09-26 03:25:36.856: E/AndroidRuntime(19979): FATAL EXCEPTION: main
09-26 03:25:36.856: E/AndroidRuntime(19979): Process: com.soheil.prolight, PID: 19979
09-26 03:25:36.856: E/AndroidRuntime(19979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.soheil.prolight/com.soheil.prolight.MainActivity}: android.view.InflateException: Binary XML file line #37: Error inflating class android.widget.ToggleButton
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.os.Looper.loop(Looper.java:136)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Method.invoke(Method.java:515)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
09-26 03:25:36.856: E/AndroidRuntime(19979): at dalvik.system.NativeStart.main(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class android.widget.ToggleButton
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Activity.setContentView(Activity.java:1929)
09-26 03:25:36.856: E/AndroidRuntime(19979): at com.soheil.prolight.MainActivity.onCreate(MainActivity.java:84)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Activity.performCreate(Activity.java:5231)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 12 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: java.lang.reflect.InvocationTargetException
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Constructor.constructNative(Native Method)
09-26 03:25:36.856: E/AndroidRuntime(19979): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 28 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/btn_toggle_bg.xml from drawable resource ID #0x7f020005
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.Resources.loadDrawable(Resources.java:2096)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.XResources$XTypedArray.getDrawable(XResources.java:965)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.view.View.<init>(View.java:3554)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.TextView.<init>(TextView.java:623)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.Button.<init>(Button.java:107)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.CompoundButton.<init>(CompoundButton.java:68)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.ToggleButton.<init>(ToggleButton.java:51)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.widget.ToggleButton.<init>(ToggleButton.java:64)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 31 more
09-26 03:25:36.856: E/AndroidRuntime(19979): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag LinearLayout
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
09-26 03:25:36.856: E/AndroidRuntime(19979): at android.content.res.Resources.loadDrawable(Resources.java:2092)
09-26 03:25:36.856: E/AndroidRuntime(19979): ... 39 more
Your drawable names cannot start with numbers:
Rename all of them to, for example:
<item android:drawable="#drawable/d1" android:duration="50"/>
<item android:drawable="#drawable/d2" android:duration="50"/>
...
Here are the naming rules you should follow:
needs to start with a letter and not a number
cannot contain upper case letters
cannot contain anything other than letters and numbers
Move you "btn_toggle_bg.xml" file from "res\drawable-hdpi" to "res\drawable" folder.
It will resolve the issue

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").

NullPointerException trying to add a widget to a custom Launcher

I'm getting a NullPointerException after calling updateAppWidgetSize() in my app (which is basically AOSP's Jelly Bean Launcher)
Output is as follows:
09-26 00:47:34.681: E/AndroidRuntime(2026): FATAL EXCEPTION: main
09-26 00:47:34.681: E/AndroidRuntime(2026): java.lang.NullPointerException
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Parcel.readException(Parcel.java:1431)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Parcel.readException(Parcel.java:1379)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetOptions(IAppWidgetService.java:535)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetManager.updateAppWidgetOptions(AppWidgetManager.java:353)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetHostView.updateAppWidgetOptions(AppWidgetHostView.java:256)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetHostView.updateAppWidgetSize(AppWidgetHostView.java:245)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.AppWidgetResizeFrame.updateWidgetSizeRanges(AppWidgetResizeFrame.java:339)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.LauncherAppWidgetInfo.notifyWidgetSizeChanged(LauncherAppWidgetInfo.java:84)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.completeAddAppWidget(Launcher.java:1153)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.addAppWidgetImpl(Launcher.java:1591)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.addAppWidgetFromDrop(Launcher.java:1653)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Workspace$8.run(Workspace.java:3071)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Workspace$9.run(Workspace.java:3266)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.DragLayer$3.onAnimationEnd(DragLayer.java:628)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1018)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator.access$400(ValueAnimator.java:51)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:623)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:639)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer.doFrame(Choreographer.java:524)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Handler.handleCallback(Handler.java:615)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Handler.dispatchMessage(Handler.java:92)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Looper.loop(Looper.java:137)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-26 00:47:34.681: E/AndroidRuntime(2026): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 00:47:34.681: E/AndroidRuntime(2026): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-26 00:47:34.681: E/AndroidRuntime(2026): at dalvik.system.NativeStart.main(Native Method)
I had to make some slight modifications to the AOSP launcher source to remove some private API use, as well as making a separate change so that widgets that have a AppWidgetHostView can be placed. Apart from that, I'm working with an unmodified version of the launcher that ships with AOSP (API 16).
The source is available if you are interested in seeing this issue for yourself (100% occurrence rate when attempting to add the Analog Clock or Messages widgets).
Any help would be appreciated.

viewflipper not works on 4.0

i have developed an application that works fine on android 2.1 version but when i launch it on android 4.0 version it does not run and throws the stack trace like this:
09-26 19:45:10.961: E/AndroidRuntime(785): FATAL EXCEPTION: main
09-26 19:45:10.961: E/AndroidRuntime(785): java.lang.OutOfMemoryError
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.nativeCreate(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.loadDrawable(Resources.java:1937)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.getDrawable(Resources.java:664)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.resolveUri(ImageView.java:542)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.setImageResource(ImageView.java:315)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.deedatech.AnimalsNameForKids.AnimalsNameForKidsActivity.onCreate(AnimalsNameForKidsActivity.java:85)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Activity.performCreate(Activity.java:4465)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:4340)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at dalvik.system.NativeStart.main(Native Method)
i just dont understand why this happens because the same program runs perfect on android 2.1 version but throws outOfMemoryError on 4.0 version. please help if u have some idea..
If you are decoding a Bitmap from the UI thread, there is a risk to get the outOfMemoryError. Try to change your decode stream to an asynTask.
Contrary to what Anis said, decoding yor Bitmap on a different thread will not help you avoid an Out Of Memory (OOM) Error, you're still loading exactly the same amount of data into your application.
You need to either reduce the size of the image you are loading or downsample it so you aren't loading in all of the data, for more information on this take a look at Loading Large Bitmaps Efficiently.

Exception when running cocos2dxsample project(Raywenderlich tutorial Cocos2D-X for iOS and Android)

I am following Cocos2D-X for iOS and Android: Getting Started tutorial from Raywenderlich site.
I have downloaded the android project from create-android-project.sh command as stated in the site. When I try to run the project in eclipse I got the following logs:
09-26 13:04:05.081: W/dalvikvm(517): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/a/samplecocos2dxandroid21;
09-26 13:04:05.081: W/dalvikvm(517): Class init failed in newInstance call (Lcom/a/samplecocos2dxandroid21;)
09-26 13:04:05.081: D/AndroidRuntime(517): Shutting down VM
09-26 13:04:05.081: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
09-26 13:04:05.091: E/AndroidRuntime(517): FATAL EXCEPTION: main
09-26 13:04:05.091: E/AndroidRuntime(517): java.lang.ExceptionInInitializerError
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Class.newInstanceImpl(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Class.newInstance(Class.java:1319)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:137)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 13:04:05.091: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load game: findLibrary returned null
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Runtime.loadLibrary(Runtime.java:365)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.System.loadLibrary(System.java:535)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.a.samplecocos2dxandroid21.<clinit>(samplecocos2dxandroid21.java:106)
09-26 13:04:05.091: E/AndroidRuntime(517): ... 15 more
android ndk, android sdk path setting and change an create-android-project.sh already done.
Can somebody please tell me where I am wrong and what is the solution of that..,.
you didn't run the build_native.sh so that your game is not built to a shared lib, that is why it complain about Can't find library

Categories

Resources