मैंने हाल ही में रूट उपयोगकर्ताओं के लिए यह application बनाया है जो अक्सर उनके डिवाइस को संशोधित करते हैं।एप्लिकेशन इंस्टॉल आकार फोन पर कैसे भिन्न होता है?
अब मैंने एप्लिकेशन के इंस्टॉल आकार के साथ बहुत अजीब व्यवहार देखा है।
जब मैंने एक्सएमएल फ़ाइल से शुरू किए गए विचारों के साथ एक नियमित गतिविधि का उपयोग किया, तो आकार 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 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 विधि के अंदर::
animation.setDuration(1000);
animation.setFillAfter(false);
जो बाद मैं यह onClickListener
में कहा जाता है:
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
बिट प्रश्न के लिए समझ में आता है।
उस संदर्भ को जोड़ना जिसमें विचार आरंभ किए गए हैं, स्मृति उपयोग को कम करते हैं?
आप अपने एपीके को अनजिप कर सकते हैं और इसके घटकों का विश्लेषण कर सकते हैं। आप इसकी संरचना देखने के लिए डीएक्स फ़ाइल (http://code.google.com/p/smali) को भी विच्छेदित कर सकते हैं। –
एपीके का आकार समान है। स्थापना का आकार अलग है। –
वाह, यह दिलचस्प है। एक रूट डिवाइस पर आप एक स्थापित अनुप्रयोग से संबंधित व्यक्तिगत फ़ाइलों का विश्लेषण कर सकते हैं, हालांकि। जैसे, 'ls -l/data/app/{package} ',' ls -l/data/data/{package} '। –