难道Android的为升级旧手机一大堆选项工作ICS?选项、工作、手机、Android

2023-09-04 11:14:20 作者:acolasia(放纵)

我有一个Galaxy Nexus的自己,我知道,安卓largeHeap =真正的清单选项可这个电话,但我想知道,如果它的工作正在升级到冰淇淋三明治旧手机,即三星Nexus S。

为什么我问的原因是,我已经建立了一个应用程序,使大量使用大位图和应用程序最初是专为48 MB的堆大小的片剂。银河的Nexus还具有48 MB的可用堆大小为每个应用程序,所以我的应用程序正在美丽的这款手机,尽管它不是一个平板电脑。

的问题是,Nexus S的只有32 MB的堆可用的,所以我真的需要一大堆选项的应用程序使用ICS的工作,这些旧手机。

我的问题:是否安卓largeHeap 选项仍然增加可用的堆内存?即如果Nexus S的有32 MB默认情况下,我将能够使用此访问perhap 64 MB可用?

对于那些你不熟悉这个选项,它增加了可用的堆内存量为您的应用程序在性能较低的成本。当没有其他选择时,才应使用。的

更新

下面是应用程序包,以显示您的可用堆大小: http://michellbak.dk/TestHeapSize.apk

该人士$ ​​C $ c是下面要告诉你,没有什么有害的:

 包com.miz.heapsize;

进口android.app.Activity;
进口android.app.ActivityManager;
进口android.os.Bundle;
进口android.widget.TextView;

公共类MainActivity延伸活动{

    私人TextView的文字;

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

        ActivityManager点=((ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE));
        INT内存= am.getMemoryClass();
        INT largeMemory = am.getLargeMemoryClass();

        文=(TextView的)findViewById(R.id.textView1);
        text.setText(正常堆大小:+内存+\ nLarge堆大小:+ largeMemory);

    }
}
 
器 度不凡 智器T20升级至Android4.0.4

清单文件:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.miz.heapsize
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <使用-SDK安卓的minSdkVersion =11/>

    <应用
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:largeHeap =真正的>
        <活动
            机器人:标签=@字符串/ APP_NAME
            机器人:名称=MainActivity。>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>

< /舱单>
 

解决方案

安卓largeHeap 选项适用于运行Android 3.0或以上的所有设备。这包括已升级到ICS的设备。

这是说,你不能保证得到48 MB的空间。提供给应用程序的确切堆大小是一个选项设备制造商可以在每台设备上设置的。在一般情况下,具有较大的显示装置将具有较大的堆大小配置

I've got a Galaxy Nexus myself, and I know that the android:largeHeap="true" manifest option works on this phone, but I was wondering if it's working on older phones that are being upgraded to Ice Cream Sandwich, i.e. the Samsung Nexus S.

The reason why I'm asking is that I've built an application that makes heavy use of large bitmaps and the application was originally designed for tablets with 48 MB of heap size. The Galaxy Nexus also features 48 MB of available heap size for each application, so my application is working beautifully on this phone despite it not being a tablet.

The problem is that the Nexus S only has 32 MB of heap available, so I really need the large heap option for the application to work on these older phones with ICS.

My question: Does the android:largeHeap option still increase the of available heap memory? I.e. if the Nexus S has 32 MB by default, will I be able to access perhap 64 MB available by using this?

For those of you unfamiliar with this option, it increases the amount of available heap memory for your application at the cost of lower performance. It should only be used when there's no other alternative.

Update

Here's the application package to show your available heap size: http://michellbak.dk/TestHeapSize.apk

The source code is below to show you that there's nothing harmful:

package com.miz.heapsize;

import android.app.Activity;
import android.app.ActivityManager;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

    private TextView text;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ActivityManager am = ((ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE));
        int memory = am.getMemoryClass();
        int largeMemory = am.getLargeMemoryClass();

        text = (TextView) findViewById(R.id.textView1);
        text.setText("Normal heap size: " + memory + "\nLarge heap size: " + largeMemory);

    }
}

Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.miz.heapsize"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="11" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true" >
        <activity
            android:label="@string/app_name"
            android:name=".MainActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

解决方案

The android:largeHeap option is available on all devices running Android 3.0 or above. This includes devices that have been upgraded to ICS.

That said, you're not guaranteed to get 48 MB of space. The exact heap size provided to applications is an option device manufacturers can set on a per-device basis. In general, devices with a larger display will be configured with larger heap sizes.