java - Static vs non static Activity intent calling method -


here little bit confuse static intent calling method vs direct intent calling. better choice creating new activity memory point of view?

as per know if intent method calling static contains memory application lives. true or not?

let move take example :

in activity b

public static intent newintent(context context) {        intent intent = new intent(context, b.class);        return intent;    } 

calling activity b activity a

in activity a

 startactivity(b.newintent(this)); 

or

in other way direct calling activity can not live after finish() calling activity. right?

startactivity(new intent(context, b.class)); 

still guess second better code point of , memory point of view. see many projects contains first(static calling) method. want know better selection calling new activity?

the method public static intent newintent() static, that's static. use of static method can call b.newintent() without having instance of b.

the context pass b.newintent(this) not static , therefore not matter if create intent in a or in b.

this in a

startactivity(b.newintent(this)); 

is no different in a

startactivity(newintent(this));  private intent newintent(context context) {    intent intent = new intent(context, b.class);    return intent; } 

so want know better selection calling new activity?

in functionality makes no difference. if there difference in memory usage, little won't notice it.

as far coding style goes, better keep creation of intent in a, because a starting b, , b should not care how a takes care of it.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -