android-memory

Application class variables gets uninitialised in android

拜拜、爱过 提交于 2019-12-24 05:47:05
问题 I have created an android app in which i'm using an application class to store and access the global variables. But i came across a strange behavior that all the variables in my application class gets uninitialized in the following scenarios, if my app is idle for sometime(say 10 minutes or so). if my app goes to background (if a browser gets opened above the app). I searched a lot in SO and web and doesn't found any suitable answer. AFAIK once application class is initialized it will be

Unbinding drawables onPause() causing unresponsive back navigation and skipping this step cause memory overflow

ぃ、小莉子 提交于 2019-12-23 09:26:54
问题 I am using an image to set as the background for all my activities but it was causing a memory overflow issue and crash the app. Now I am unbinding my drawables on pause() and on Destroy() in my activity and now it shows blank screen on pressing back button. So how can I avoid this without using extra memory. protected void onPause(){ super.onPause(); unbindDrawables(findViewById(R.id.login_root)); } protected void onDestroy() { unbindDrawables(findViewById(R.id.login_root)); super.onDestroy(

Saving to SD card as text file

二次信任 提交于 2019-12-17 23:35:04
问题 stopWriting = (Button) findViewById(R.id.save); stopWriting.setOnClickListener(new OnClickListener() { @SuppressLint("SdCardPath") public void onClick(View v) { // stop recording the sensor data try { myFile = new File("/sdcard/SensorData/" + txtData.getText() + ".txt"); myFile.createNewFile(); sData = new FileOutputStream(myFile); myOutWriter = new OutputStreamWriter(sData); myBufferedWriter = new BufferedWriter(myOutWriter); myPrintWriter = new PrintWriter(myBufferedWriter); //if(myFile !=

android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>

我的梦境 提交于 2019-12-17 09:46:10
问题 I am developing a simple app. Just finished the home screen. If the orientation changes more than two times, it is throwing the error and application is force closing. My activity Code : public class PasswordActivity extends Activity implements OnClickListener { Button login; Button forgot; Button register; private static final String PREFERENCES = "prefs"; private static final String PREFERENCES_NAME = "pref_name"; SharedPreferences settings; private Cursor c; @Override public void onCreate

Avoiding out of memory error in loading bitmap in listview

懵懂的女人 提交于 2019-12-13 12:22:45
问题 I am having an listview and i am loading bitmaps in it from the web .. but now the problem is i am having 1000 item in the listview so, it is causing me out of memory error.. i have used the image caching also.. 回答1: I think using any one of the below will solve your problem Lazy List Universal ImageLoader 回答2: try the following code: public class ListFivePictureNameDetailsPassFail extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

the png loading get out of memory android

北慕城南 提交于 2019-12-13 07:44:06
问题 I have a fragment that have a grid view.I'm putting 70 images in grid view.but when i run the app it get out of memory.how o solve it?should i convert all images to bitmap? this is my fragment class: public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_games, container, false); mDrawerList = (GridView) rootView.findViewById(R.id.list_slidermenu); icons=new int[50]; for(int i=1 ;i<icons.length ;i+

RAM increase - android service

大兔子大兔子 提交于 2019-12-13 06:24:39
问题 I made some changes in my android service, like declared a hashmap of bitmaps as member variable, and populated it dynamically. I am concerned that bitmaps might take up considerable RAM. How can I confirm how much is the RAM usage increase after my changes. Is there any tool to check this ? If anybody has worked in this area before, please help ! 回答1: there are eclipse android sdk tools to detect the current heap allocation size, but there is much simpler way to know current heap size: just

App Memory Usage differs between Devices

折月煮酒 提交于 2019-12-12 17:06:06
问题 I run my App in two different devices and check from Android Studio's Memroy tab the app's allocated memory. When the app runs in the Samsung device, the allocated memory is about 60 MB. When the app runs in the Motorola device, the allocated memory is about 40 MB. What causes this differnce in memory allocation? Devices: Samsung Galaxy S4 with 5.0.1 Android Version Motorola Moto G2 with 5.0.2 Android Version 回答1: Samsung has additional layer of libraries for their custom UI on Android, which

Best Way to Animate images frame by frame in Android

筅森魡賤 提交于 2019-12-11 09:03:43
问题 I have 3 sets of 50 images and I have to create the animations for each set of images in Android application. I am able to create a simple application which animate first set of 50 images using the below method, Added Animation-list xml in drawable folder and called it using frameAnimation.start(). This method didn't work until I kept the following "android:largeHeap="true" in manifest file. I am not sure whether this is the good way to animate the images (if we have more number of images and

java.lang.OutOfMemoryError occur on the animation Loading?

对着背影说爱祢 提交于 2019-12-11 08:37:51
问题 What I get from the Developer site is "If in the loading time total size of the animation exceed the value of Virtual heap memory , this error will occur" and For the Solution use BitmapFactory . I tried in the below code : Now, the question is this, "what are responsible for this error ?" : Does dimensions of the image are count when the Images load for animation. Like : If I have 10 images dimensions( 1100 * 1100 ) and use ARGB_8888 pattern for the image. Size of images(500KB, 1MB etc )