Problem sending port-directed Data SMS on HTC EVO 4G - android

I am trying to send and receive port-directed SMS from an HTC EVO 4G to itself using SmsManager.sendDataMessage() and the device is giving a NullPointerException quite deep in the OS.
Here is the code that kicks off the exception:
manager.sendDataMessage(phonenumber, null, (short) 8091, data,piSend, piDelivered);
I think I have the appropriate permissions declared in the manifest:
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
Here's the stack trace I'm getting:
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): FATAL EXCEPTION: main
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): java.lang.NullPointerException
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.os.Parcel.readException(Parcel.java:1328)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.os.Parcel.readException(Parcel.java:1276)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.android.internal.telephony.ISms$Stub$Proxy.sen dData(ISms.java:682)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.telephony.SmsManager.sendDataMessage(SmsMa nager.java:546)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.varma.samples.smsdemo.MainActivity.sendSms(Mai nActivity.java:66)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.varma.samples.smsdemo.MainActivity.access$0(Ma inActivity.java:50)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.varma.samples.smsdemo.MainActivity$1.onClick(M ainActivity.java:98)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.view.View.performClick(View.java:2532)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.view.View$PerformClick.run(View.java:9293)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.os.Handler.handleCallback(Handler.java:587 )
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.os.Handler.dispatchMessage(Handler.java:92 )
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.os.Looper.loop(Looper.java:143)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at android.app.ActivityThread.main(ActivityThread.jav a:4263)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at java.lang.reflect.Method.invoke(Method.java:507)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:839)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:597)
06-27 11:03:42.144: ERROR/AndroidRuntime(14489): at dalvik.system.NativeStart.main(Native Method)
If anybody wants to try it out for themselves, I am using the example provided here in the SMSDemo project.
Can anybody help me out with this?
EDIT :
I have just put together a sample J2ME MIDlet to see if I can get it to work as well and it also fails. Does anybody remember any information about port-directed SMS? Is it handled differently on different networks? Is it all just outdated and I need to get with the times? Or is it something that I might be doing?
In case SMS is network dependent, I'm using Sprint devices but I'm developing in Canada, so I think they are roaming on Telus.

Related

Having issues integrating Scandit SDK into my app

Decided to use Scandit SDK to get the barcode scanning feature in my app. Unfortunately, since I'm relatively new to Android development and Java in general I've run into a few issues that I can't seem to work out. The demo that Scandit provided doesn't give any errors(runs fine) but crashes when I try to start it up (pressing a button from one activity is meant to start it up). I've tried reading the logcat and googling a solution to the problems but I'm not getting the right solutions. Does anyone have an idea of what I'm doing wrong?
Logcat is provided below:
10-08 23:30:00.807 21563-21563/com.kwesimbia.management D/AndroidRuntime? Shutting down VM
10-08 23:30:00.807 21563-21563/com.kwesimbia.management W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x40aa4228)
10-08 23:30:00.817 21563-21563/com.kwesimbia.management E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3082)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.kwesimbia.management.ScanditSDKDemoSimple
at com.kwesimbia.management.Activity_D.initiateCodeScan(Activity_D.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Process: com.kwesimbia.management
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Package: com.kwesimbia.management v1 (1.0)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger?
Application Label: firstapp
10-08 23:30:00.827 32726-587/? W/ActivityManager?
Force finishing activity com.kwesimbia.management/.Activity_D
I came across this problem as well, my solution was to extract the library files and put them as their files in the lib folder
The library basically isn't being exported with it
EDIT
So I checked out my project, basically I did these things:
In the libs folder I have a new folder called armeabi and inside that I have libscanditsdk-android-3.3.1.so
Then in my build path I have also referenced the jar file that they provide:
<classpathentry exported="true" kind="lib" path="C:/GIT/Android/FwayScannerProject/FwayScanner/libs/scanditsdk-barcodepicker-android-3.3.1.jar"/>

Selecting an item in ListFragment list programmatically

I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
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:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}

Google Maps Android API v2 gives an "The application *** has stopped unexpectedly" Error

I am following Google Maps Android API v2 setup guide and I did everything in the guide but the things don't seem to work and I get "The application mapdemo (process com.example.mapdemo) has stopped unexpectedly. Please try again". I have wasted 1 whole day and still cannot find a solution. :(
My Manifest file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mapdemo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyC253yRJk8FVwFbuGiMOTn5Cp7C2vdTMx4" />
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
MainActivity.java
package com.example.mapdemo;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
LogCat output is:
06-27 10:58:09.263: D/AndroidRuntime(18097): Shutting down VM
06-27 10:58:09.263: W/dalvikvm(18097): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
06-27 10:58:09.273: E/AndroidRuntime(18097): FATAL EXCEPTION: main
06-27 10:58:09.273: E/AndroidRuntime(18097): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.os.Looper.loop(Looper.java:143)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.main(ActivityThread.java:4196)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.reflect.Method.invoke(Method.java:507)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-27 10:58:09.273: E/AndroidRuntime(18097): at dalvik.system.NativeStart.main(Native Method)
06-27 10:58:09.273: E/AndroidRuntime(18097): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.Activity.setContentView(Activity.java:1702)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:11)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
06-27 10:58:09.273: E/AndroidRuntime(18097): ... 11 more
06-27 10:58:09.273: E/AndroidRuntime(18097): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.mapdemo-2.apk]
06-27 10:58:09.273: E/AndroidRuntime(18097): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-27 10:58:09.273: E/AndroidRuntime(18097): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
06-27 10:58:09.273: E/AndroidRuntime(18097): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-27 10:58:09.273: E/AndroidRuntime(18097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
06-27 10:58:09.273: E/AndroidRuntime(18097): ... 19 more
The error is so frustrating. Any help will be greatly appreciated. Thanks
The error says that the class is not found. There seems to be an issue with the way you added google-play-services project(support libray), if at all you did. Checkout:
Error java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in Google Map V2
Unable instantiate android.gms.maps.MapFragment
java.lang.noclassdeffounderror: com.google.android.gms.R$styleable nothing helped me
They talk about similar issue. Hope it helps.

java.lang.IndexOutOfBoundsException: Invalid index x, size is y

I have an activity where there are 2 spinners. I fill the spinners with lists taken from an xml file like this one :
<outil id="1" name="Décompacteur">
<travail id="1">Travail au sol</travail>
<travail id="1001">Autre</travail>
</outil>
<outil id="2" name="Cultivateur">
<travail id="3">Travail au sol</travail>
<travail id="1002">Autre</travail>
</outil>
In another activity, I can change the file from which I build the lists.
My problem is : I select a tool (outil) at the end of a long list of tools, for example position = 6. Then I change the file, and the tool list now has only 4 items. I set a new adapter :
listNameOutil = getOutilNameList(listOutilObject);
adapterOutil = new ArrayAdapter<String>(this, R.layout.spinners_base, listNameOutil);
adapterOutil.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_outil.setAdapter(adapterOutil);
But I still get an error, and I don't know where it comes from provided there is no "caused by" in the stack trace... Please note that I also do a spinner_outil.setSelection(positionSaved);. At first, I was trying to catch the exception on this line but it seems that it's not this line which is the problem.
Any ideas to solve this?
Here is the Stack trace :
06-27 14:46:01.811: W/dalvikvm(20824): threadid=1: thread exiting with uncaught exception (group=0x40d0c930)
06-27 14:46:01.821: E/AndroidRuntime(20824): FATAL EXCEPTION: main
06-27 14:46:01.821: E/AndroidRuntime(20824): java.lang.IndexOutOfBoundsException: Invalid index 6, size is 4
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.util.ArrayList.get(ArrayList.java:304)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:337)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:390)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.Spinner.makeAndAddView(Spinner.java:546)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.Spinner.layout(Spinner.java:495)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.Spinner.onLayout(Spinner.java:459)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.View.layout(View.java:14008)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.View.layout(View.java:14008)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.View.layout(View.java:14008)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.View.layout(View.java:14008)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.View.layout(View.java:14008)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.Choreographer.doFrame(Choreographer.java:532)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.os.Handler.handleCallback(Handler.java:725)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.os.Handler.dispatchMessage(Handler.java:92)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.os.Looper.loop(Looper.java:137)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.lang.reflect.Method.invoke(Method.java:511)
06-27 14:46:01.821: E/AndroidRuntime(20824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-27 14:46:01.821: E/AndroidRuntime(20824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-27 14:46:01.821: E/AndroidRuntime(20824): at dalvik.system.NativeStart.main(Native Method)
EDIT :
In the on Start, I bind to my service. Then, in onServiceConnected, I ask the service for configuration informations :
try {
remoteServiceMain.requeteLireConfig();
} catch (RemoteException e) {
e.printStackTrace();
}
Then, still in the onServiceConnected, I define the layout :
spinner_outil = (Spinner) findViewById(R.id.spinner_outil_layout);
spinner_outil.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
}
}
Then onServiceConnected is finished. Please note that I get the last log before error there.
REDDIT :
I do setSelection(positionSaved); after spinner_outil.setAdapter(adapterOutil);, and I set positionSaved when I get the answer from the service after calling :
try {
remoteServiceMain.requeteLireConfig();
} catch (RemoteException e) {
e.printStackTrace();
}
positionSaved is sent by the Service, which takes it from a Configuration File. positionSaved is saved evrytime the user clicks on an Item of the spinner. The reason why I get it from the service and not directly from the File is that I use the same method for other things

Memory leaks in android

I am developing an application that deals with storing lot of images in cache, I frequently encounter error like - out of memory. Can anyone suggest a way to deal with this issue
Error Log
Report of logcat :
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): FATAL EXCEPTION: main
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:450)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.content.res.Resources.loadDrawable(Resources.java:1709)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.content.res.Resources.getDrawable(Resources.java:581)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.view.View.setBackgroundResource(View.java:7533)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at com.lht.icruise.activity.shipdetails.ShipDetailsActivity.onCreate(ShipDetailsActivity.java:99)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.os.Looper.loop(Looper.java:123)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at android.app.ActivityThread.main(ActivityThread.java:3647)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at java.lang.reflect.Method.invoke(Method.java:507)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-27 19:41:16.425: ERROR/AndroidRuntime(13965): at dalvik.system.NativeStart.main(Native Method)
If you using large bitmaps, recycling the bitmaps to free up memory using recycle() method on bitmap when that bitmap no more used, might help you.
Check if this answer helps you: Strange out of memory issue while loading an image to a Bitmap object

Categories

Resources