私は最近、自分のデバイスを頻繁に改造するrootユーザーのためにこれをapplicationにしました。アプリケーションのインストールサイズは電話でどのように変化しますか?
今、私はアプリケーションのインストールサイズで非常に奇妙な動作に気付きました。
XMLファイルからビューを初期化して通常のアクティビティを使用したとき、サイズは715 kb
でした。
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main_layout);
executeEvents = new ExecuteEvents(this);
display = (TextView) findViewById(R.id.display);
powermenu = (Button) findViewById(R.id.powermenu);
turnoffscreen = (Button) findViewById(R.id.turnscreenoff);
mapButton = (ImageButton) findViewById(R.id.mapButton);
SP = getSharedPreferences(PBConstants.Power_Button_SP, MODE_MULTI_PROCESS);
if(SP.contains(PBConstants.INPUT_DEVICE_TAG))
display.setText(getResources().getString(R.string.configured));
mapButton.setOnClickListener(this);
powermenu.setOnClickListener(this);
turnoffscreen.setOnClickListener(this);
}
私が作成したダイアログに切り替えた後、XMLファイルのウィジェットを含むビューを設定しました。アプリのサイズは200kb
になりました。私はこれを使用する場合
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
//setContentView(R.layout.main_layout);
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.main_layout, null);
executeEvents = new ExecuteEvents(this);
display = (TextView) view.findViewById(R.id.display);
powermenu = (Button) view.findViewById(R.id.powermenu);
turnoffscreen = (Button) view.findViewById(R.id.turnscreenoff);
mapButton = (ImageButton) view.findViewById(R.id.mapButton);
SP = getSharedPreferences(PBConstants.Power_Button_SP, MODE_MULTI_PROCESS);
if(SP.contains(PBConstants.INPUT_DEVICE_TAG))
display.setText(getResources().getString(R.string.configured));
mapButton.setOnClickListener(this);
powermenu.setOnClickListener(this);
turnoffscreen.setOnClickListener(this);
Dialog dialog = new Dialog(this);
dialog.setContentView(view);
dialog.setTitle(getResources().getString(R.string.app_name));
dialog.show();
}
それは80kb
に減少:私はまた、アプリケーションのサイズで別の奇妙な変化に気づい
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
dialog = new Dialog(this);
dialog.setContentView(R.layout.main_layout);
executeEvents = new ExecuteEvents(this);
display = (TextView) dialog.findViewById(R.id.display);
powermenu = (Button) dialog.findViewById(R.id.powermenu);
turnoffscreen = (Button) dialog.findViewById(R.id.turnscreenoff);
mapButton = (ImageButton) dialog.findViewById(R.id.mapButton);
SP = getSharedPreferences(PBConstants.Power_Button_SP, MODE_MULTI_PROCESS);
if(SP.contains(PBConstants.INPUT_DEVICE_TAG))
display.setText(getString(R.string.configured));
mapButton.setOnClickListener(this);
powermenu.setOnClickListener(this);
turnoffscreen.setOnClickListener(this);
dialog.setTitle(getString(R.string.app_name));
dialog.show();
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
dialog.dismiss();
MainActivity.this.finish();
}
});
}
を、私は、コードの最後のスタイルでアニメーションを追加しようとしたとき(80kb
1) 。アプリのサイズはひどく1 MB
になりました。これは私がアニメーションを初期化し、ボタンがクリックされたときにそれを呼び出してみました方法です:
private static final ScaleAnimation animation = new ScaleAnimation(1, .95f, 1, .95f, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);//declared as global variable
のonCreateメソッド内:私はonClickListener
でそれを呼ば
animation.setDuration(1000);
animation.setFillAfter(false);
た後:
mapButton.startAnimation(animation);
新しいリソースを追加せずにコードのスタイルのみを変更した場合、アプリケーションサイズが大幅に変化するのはなぜですか?ダイアログの中にあるウィジェットを初期化する方法には、このような大きな違いがどこにありますか?私が追加した方法でアニメーションを追加すると、なぜ大きな違いがありますか?
は質問をフォローアップ:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main_layout);
executeEvents = new ExecuteEvents(this);
display = (TextView) this.findViewById(R.id.display);
powermenu = (Button) this.findViewById(R.id.powermenu);
turnoffscreen = (Button) this.findViewById(R.id.turnscreenoff);
mapButton = (ImageButton) this.findViewById(R.id.mapButton);
SP = getSharedPreferences(PBConstants.Power_Button_SP, MODE_MULTI_PROCESS);
if(SP.contains(PBConstants.INPUT_DEVICE_TAG))
display.setText(getResources().getString(R.string.configured));
mapButton.setOnClickListener(this);
powermenu.setOnClickListener(this);
turnoffscreen.setOnClickListener(this);
}
投機
が、これは輸入されているパッケージまたはクラスが原因だろうか?質問のanimation
ビットは少なくとも意味があります。
ビューが初期化されるコンテキストを追加すると、メモリ使用量が減少しますか?
APKを解凍し、コンポーネントを分析することができます。 dexファイル(http://code.google.com/p/smali)を解析してその構造を見ることもできます。 –
APKのサイズは同じです。インストールサイズが異なります。 –
うわー、それは面白いです。ルートデバイス上では、インストールされたアプリケーションに関連する個々のファイルを分析することができます。 'ls -l/data/app/{package}'、 'ls -l/data/data/{package}'と同様です。 –