Will many import statements in a activity/apps affect performance in android.
Example situation 1:
In a activity/public class (Let’s called it DialogHelper.java) , I handle all the apps dialog in this single DialogHelper.java and I have multiple import statements in that activity , will it effect the runtime performance or have any effect on the phone memory or slow down the performance?
Example situation 2:
Instead of using this catch (Exception e) which require no import at all
try {
String url = "data";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
activity.startActivity(i);
} catch (Exception e) {
//Exception here
}
I used this, which require to import android.content.ActivityNotFoundException; , which one is better?
try {
String url = "data";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
activity.startActivity(i);
} catch (ActivityNotFoundException e) {
//Exception here
}
Realistically, unless you’re importing hundreds of classes, I doubt you’ll see any performance decrease.
That being said, in practice you should only import what you need. I.e. If you need something specific from that ActivityNotFoundException, or only want to catch that type of exception, definitely use it. But if you don’t, using its superclass will take a very slight load off of the performance.