i have a spinner and when you select an item from the spinner a text from a string should show in the textView, (txtdescription1) but when i start the activity it crashes.
i have tested a lot of thing but i dont find a error in the code.
Resources res = getResources();
int[] txt = res.getIntArray(R.array.description);
public void onItemSelected(AdapterView<?> parent, View v, int position,
long id) {
txtdescription1.setText(txt[position]);
}
Here is the LogCat
12-27 00:37:24.895: E/AndroidRuntime(1267): FATAL EXCEPTION: main
12-27 00:37:24.895: E/AndroidRuntime(1267): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.alpha.liveshit/com.alpha.liveshit.Sample}: java.lang.NullPointerException
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.os.Looper.loop(Looper.java:123)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.reflect.Method.invoke(Method.java:521)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-27 00:37:24.895: E/AndroidRuntime(1267): at dalvik.system.NativeStart.main(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): Caused by: java.lang.NullPointerException
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
12-27 00:37:24.895: E/AndroidRuntime(1267): at com.alpha.liveshit.Sample.<init>(Sample.java:42)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.Class.newInstanceImpl(Native Method)
12-27 00:37:24.895: E/AndroidRuntime(1267): at java.lang.Class.newInstance(Class.java:1429)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-27 00:37:24.895: E/AndroidRuntime(1267): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-27 00:37:24.895: E/AndroidRuntime(1267): ... 11 more
You appear to be calling getResources() from your activity's constructor. Your activity should not have a constructor (or, at least, not one that interacts with the framework in any way). It hasn't been properly initialized at that point (which is why the call to getResources() is throwing a NPE). Put all your initialization code in onCreate(Bundle).
Related
I'm using solution of Scroll webview horizontally inside a ViewPager
it's looks very useful, I was reference ExtendedWebView in xml,
<ExtendedWebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
instance ExtendedWebView in .class,
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = mInflater.inflate(R.layout.lay1, null);
ExtendedWebView webView = (ExtendedWebView)layout.findViewById(R.id.webview);
but i got 'Error inflating class ExtendedWebView', so could anybody to help me to give me some ideas, thanks for your time and experience!
heres are entire stack trace,
12-27 22:14:44.263: E/AndroidRuntime(10824): FATAL EXCEPTION: main
12-27 22:14:44.263: E/AndroidRuntime(10824): android.view.InflateException: Binary XML file line #7: Error inflating class com.vv_package_name.ExtendedWebView
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.vv_package_name.vv_main$ExtendedPagerAdapter.instantiateItem(vv_main.java:135)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.populate(ViewPager.java:930)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.os.Looper.loop(Looper.java:123)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.reflect.Method.invoke(Method.java:521)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-27 22:14:44.263: E/AndroidRuntime(10824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-27 22:14:44.263: E/AndroidRuntime(10824): at dalvik.system.NativeStart.main(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824): Caused by: java.lang.ClassNotFoundException: com.vv_package_name.ExtendedWebView in loader dalvik.system.PathClassLoader[/data/app/com.vv_package_name-2.apk]
12-27 22:14:44.263: E/AndroidRuntime(10824): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-27 22:14:44.263: E/AndroidRuntime(10824): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
12-27 22:14:44.263: E/AndroidRuntime(10824): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
12-27 22:14:44.263: E/AndroidRuntime(10824): ... 33 more
if using WebView instead of ExtendedWebView, my code is working fine :)
You need to provide a full reference to the class, including the package.
For instance,
<org.example.myapp.ExtendedWebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
sorry i'm a noob, it's my problem, i put these extend webview code in main Activity class in one .class file...it should be save with a standalone .class file...:)
public class ExtendedWebView extends WebView {
Solved for me by using this in my XML:
<view
class="com.example.MainActivity$MyWebView"
android:id="#+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
My app stopped working after requesting location updates in android emulator. This happens only for android versions over 3.0.
Any code like the following
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
the app stops working. Is this a regular behavior in simulator for these versions or am I doing something wrong?
More info: If I launch the simulator for android 2.3 or less, the exceptions are being caught properly. This is not happening in the other versions.
12-27 19:17:59.183: W/dalvikvm(640): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
12-27 19:17:59.253: E/AndroidRuntime(640): FATAL EXCEPTION: main
12-27 19:17:59.253: E/AndroidRuntime(640): android.os.NetworkOnMainThreadException
12-27 19:17:59.253: E/AndroidRuntime(640): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
12-27 19:17:59.253: E/AndroidRuntime(640): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
12-27 19:17:59.253: E/AndroidRuntime(640): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
12-27 19:17:59.253: E/AndroidRuntime(640): at java.net.InetAddress.getAllByName(InetAddress.java:214)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
12-27 19:17:59.253: E/AndroidRuntime(640): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
12-27 19:17:59.253: E/AndroidRuntime(640): at com.rahul.places.AddNewLocation.getUrlArray(AddNewLocation.java:147)
12-27 19:17:59.253: E/AndroidRuntime(640): at com.rahul.places.AddNewLocation.access$6(AddNewLocation.java:139)
12-27 19:17:59.253: E/AndroidRuntime(640): at com.rahul.places.AddNewLocation$2.onClick(AddNewLocation.java:69)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.view.View.performClick(View.java:4084)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.view.View$PerformClick.run(View.java:16966)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.os.Handler.handleCallback(Handler.java:615)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.os.Handler.dispatchMessage(Handler.java:92)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.os.Looper.loop(Looper.java:137)
12-27 19:17:59.253: E/AndroidRuntime(640): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-27 19:17:59.253: E/AndroidRuntime(640): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 19:17:59.253: E/AndroidRuntime(640): at java.lang.reflect.Method.invoke(Method.java:511)
12-27 19:17:59.253: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-27 19:17:59.253: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-27 19:17:59.253: E/AndroidRuntime(640): at dalvik.system.NativeStart.main(Native Method)
This is expected. Android is much more strict in dealing with work on the UI thread in more recent versions.
The solution is to use a handler to change the UI on the UI thread when location updates are available (that is in your onLocationChanged() method).
I Have Tried Below tutorial For Reading Contacts In Android
http://www.edumobile.org/android/android-programming-tutorials/read-contacts-from-device/
http://eagle.phys.utk.edu/guidry/android/readContacts.html
Both Are Complete without any Error But When I Am Running It's Showing Force Close Error
I tried with API 8,13,16
Same Error For all. I Dont Know More About It But I Completly Follow Tutorial.
Catlog Here
09-30 14:02:09.121: D/AndroidRuntime(305): Shutting down VM
09-30 14:02:09.121: W/dalvikvm(305): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-30 14:02:09.141: E/AndroidRuntime(305): FATAL EXCEPTION: main
09-30 14:02:09.141: E/AndroidRuntime(305): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.app.ReadContacts/com.app.ReadContacts.ReadContacts}: java.lang.ClassNotFoundException: com.app.ReadContacts.ReadContacts in loader dalvik.system.PathClassLoader[/data/app/com.app.ReadContacts-2.apk]
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
09-30 14:02:09.141: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-30 14:02:09.141: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-30 14:02:09.141: E/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
09-30 14:02:09.141: E/AndroidRuntime(305): Caused by: java.lang.ClassNotFoundException: com.app.ReadContacts.ReadContacts in loader dalvik.system.PathClassLoader[/data/app/com.app.ReadContacts-2.apk]
09-30 14:02:09.141: E/AndroidRuntime(305): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-30 14:02:09.141: E/AndroidRuntime(305): ... 11 more
09-30 14:07:09.262: I/Process(305): Sending signal. PID: 305 SIG: 9
Have you added the com.app.ReadContacts.ReadContacts Activity to your AndroidManifest.xml?
The error you're receiving suggests that you haven't...
The line to add is probably
<activity android:name=".ReadContacts"/>
although depending on your project structure it can be necessary to use the fully qualified name
<activity android:name="com.app.ReadContacts.ReadContacts"/>
have u mentioned read contacts permission in manifest file?
<uses-permission android:name="android.permission.READ_CONTACTS" />
if yes, post the error message from log cat
It appears that the class com.app.ReadContacts.ReadContacts cannot be found. Have you specified your Activity in your AndroidManifest.xml file?
I am trying to insert images from the drawable folder to ImageView on custom listview. But when i set the images on satisfying the condition its giving the following warnings from getView.
12-27 11:56:56.356: DEBUG/skia(341): ---- read threw an exception
12-27 11:56:56.366: WARN/System.err(341): java.io.IOException: Is a directory
12-27 11:56:56.366: WARN/System.err(341): at org.apache.harmony.luni.platform.OSFileSystem.read(Native Method)
12-27 11:56:56.366: WARN/System.err(341): at dalvik.system.BlockGuard$WrappedFileSystem.read(BlockGuard.java:165)
12-27 11:56:56.366: WARN/System.err(341): at java.io.FileInputStream.read(FileInputStream.java:290)
12-27 11:56:56.366: WARN/System.err(341): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
12-27 11:56:56.366: WARN/System.err(341): at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
12-27 11:56:56.366: WARN/System.err(341): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
12-27 11:56:56.366: WARN/System.err(341): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:284)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:309)
12-27 11:56:56.378: WARN/System.err(341): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:800)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.ImageView.resolveUri(ImageView.java:528)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.ImageView.setImageURI(ImageView.java:305)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.setViewImage(SimpleAdapter.java:264)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:192)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
12-27 11:56:56.378: WARN/System.err(341): at com.presentation.activity.ShowListActivity$CustomAdapter.getView(ShowListActivity.java:229)
12-27 11:56:56.378: WARN/System.err(341): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.makeAndAddView(ListView.java:1745)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.fillDown(ListView.java:670)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.fillFromTop(ListView.java:727)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.ListView.layoutChildren(ListView.java:1598)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
12-27 11:56:56.386: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
12-27 11:56:56.386: WARN/System.err(341): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341): at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
12-27 11:56:56.396: WARN/System.err(341): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
12-27 11:56:56.396: WARN/System.err(341): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 11:56:56.396: WARN/System.err(341): at android.os.Looper.loop(Looper.java:123)
12-27 11:56:56.396: WARN/System.err(341): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-27 11:56:56.396: WARN/System.err(341): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 11:56:56.396: WARN/System.err(341): at java.lang.reflect.Method.invoke(Method.java:507)
12-27 11:56:56.396: WARN/System.err(341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-27 11:56:56.406: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.406: WARN/System.err(341): at dalvik.system.NativeStart.main(Native Method)
12-27 11:56:56.466: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.406: WARN/System.err(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.466: DEBUG/skia(341): ---- read threw an exception
12-27 11:56:56.466: DEBUG/skia(341): --- SkImageDecoder::Factory returned null
12-27 11:56:56.466: INFO/System.out(341): resolveUri failed on bad bitmap uri:
I am using a custom adapter that extends the SimpleAdapter and putting the text and icons according to condition.
My custome adapter looks something like..
serviceAdapter = new CustomAdapter(this, serviceList, R.layout.list_row,
new String[] { "name", "duration","reason", "remark", "img1", "img2", "img3",
"img" }, new int[] { R.id.servicename, R.id.duration,R.id.reason, R.id.remark,
R.id.statusImg1, R.id.statusImg2, R.id.statusImg3, R.id.isExpandable });
I am putting the corresponding values from a HashMap...
HashMap<String, Object> rowValue = new HashMap<String, Object>();
And image using. rowValue.put("img2", R.drawable.img);
Its not throwing any errors but slowing down the application a lot. Can any one let me know what the problem might be...
Check for the image name in image path. The issue may be in image path. I am sure that it points to any directory not to file.
maybe the problem is: the image file path pointer to a folder not file
I have an android programm which manage a database. It this database, I write the sensor values of my device.
When close the application with the home button, i have a force close error.
Here is my logcat, can you please help me, thank you.
`12-27 10:45:20.827: D/AndroidRuntime(1053): Shutting down VM
12-27 10:45:20.827: W/dalvikvm(1053): threadid=1: thread exiting with uncaught exception (group=0x40014760)
12-27 10:45:20.942: E/AndroidRuntime(1053): FATAL EXCEPTION: main
12-27 10:45:20.942: E/AndroidRuntime(1053): java.lang.NullPointerException
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteStatement.releaseAndUnlock(SQLiteStatement.java:283)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:116)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1732)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1605)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.CapteursBDD.insertValeursCapteur(CapteursBDD.java:69)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.EssaisCapteurs.onProximityChanged(EssaisCapteurs.java:454)
12-27 10:45:20.942: E/AndroidRuntime(1053): at milos.stationdemesure.EssaisCapteurs.onSensorChanged(EssaisCapteurs.java:354)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.hardware.SensorManager$ListenerDelegate$1.handleMessage(SensorManager.java:529)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.os.Looper.loop(Looper.java:126)
12-27 10:45:20.942: E/AndroidRuntime(1053): at android.app.ActivityThread.main(ActivityThread.java:3997)
12-27 10:45:20.942: E/AndroidRuntime(1053): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 10:45:20.942: E/AndroidRuntime(1053): at java.lang.reflect.Method.invoke(Method.java:491)
12-27 10:45:20.942: E/AndroidRuntime(1053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-27 10:45:20.942: E/AndroidRuntime(1053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-27 10:45:20.942: E/AndroidRuntime(1053): at dalvik.system.NativeStart.main(Native Method)
`
I feel the issue is either database instance or any other object became null but you are calling some method using that object. Always check for null before using any methods of any object. see the sample example
example
if(database != null){
database.close();
}
Looks similar to this issue: SQLiteDatabase close() function causing NullPointerException when multiple threads
You may not need to call database.close()