How to reduce android activity and app size?

余生颓废 提交于 2019-12-25 03:53:27

问题


I'm new at android devolpment, so I am developing an alphabet app for an old language, the app would look like this

first page has a picture and two buttons

first button links to a page with text

second button links to a page with 24 images (alphabets), if you click on one of the image (alphabet) then you move on to a page with picture (alphabet) and below the picture there is a button to listen to the pronunciation of the letter

in the end the app will contain 50 images, 24 audio files and at least 30 activity

and the app size will be too large

The question is can I use something else instead of activity? or should I use use activity then reduce the app size? ProGuard??

I am developing at android API 21 and the min Api is API 8


回答1:


You can pass data into activities and fragments in Android, there is no need to create multiple activities that have a similar function.

If you decide to use an Activity you can pass data via an Intent which can contain extras, e.g.

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("image_id", R.drawable.some_letter);
intent.putExtra("audio_file", "some_letter.mp3");
startActivity(intent);

Similarly, you can pass a Bundle of arguments to a fragment:

Fragment fragment = new NextFragment();
Bundle args = new Bundle();
args.putInt("image_id", R.drawable.some_letter);
args.putString("audio_file", "some_letter.mp3");
fragment.setArguments(args);
....



回答2:


Regardless of the size, it sounds like you would greatly benefit from using fragments in your architecture. Android Fragments

If 50 images and 24 audio files add up to too much, you might want to check the resolution of the images and/or the compression of your audio files. How much is too much?



来源:https://stackoverflow.com/questions/26746967/how-to-reduce-android-activity-and-app-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!