ActivityLifecycleHelper implementation
Description
The ActivityLifecycleHelper
uses wrap(Context)
to create the class and save a global Application
field. It then uses with(ActivityCallbacks)
to register android.app.Application.ActivityLifecycleCallbacks
on the Application
field. Whenever onActivityResumed(Activity)
is triggered the class calls a null OnSaved(Bundle)
. Whenever onActivitySaveInstanceState(Activity, Bundle)
is triggered the class calls a saved/null OnSaved(Bundle)
. It then unregisters the android.app.Application.ActivityLifecycleCallbacks
when onActivityDestroyed(Activity)
is triggered. Finally, it returns the base context of the Application
field.
ActivityLifecycleHelper.class
public class ActivityLifecycleHelper {
public interface ActivityCallbacks {
void OnSaved(Bundle savedInstance);
}
private final Application application;
private ActivityLifecycleHelper(Application application) {
this.application = application;
}
public static ActivityLifecycleHelper wrap(Context context) {
return new ActivityLifecycleHelper(assertApplication(context));
}
public Context with(final ActivityCallbacks callbacks) {
application.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity a, Bundle b) {}
@Override
public void onActivityStarted(Activity a) {}
@Override
public void onActivityResumed(Activity a) {
callbacks.OnSaved(null);
}
@Override
public void onActivityPaused(Activity a) {}
@Override
public void onActivityStopped(Activity a) {}
@Override
public void onActivitySaveInstanceState(Activity a, Bundle b) {
callbacks.OnSaved(b);
}
@Override
public void onActivityDestroyed(Activity a) {
application.unregisterActivityLifecycleCallbacks(this);
}
});
return application.getBaseContext();
}
private static Application assertApplication(Context context) {
final Context application = context.getApplicationContext();
if (application instanceof Application) return (Application) application;
throw new NullPointerException("Context must be instance of Application");
}
}
Usage
public class Usage implements ActivityLifecycleHelper.ActivityCallbacks {
private final Context context;
Usage(Context context) {
this.context = ActivityLifecycleHelper.wrap(context).with(this);
}
@Override
public void OnSaved(Bundle savedInstance) {
// doingit
}
}
Reasoning
This is used within a library that when initialized receives a context that will extend from an Application and hooks into any Activity LifeCycle events.
OnResume()
will allow the library to reset some things and onSaveInstanceState()
is so the library can rebuild.
Needed
Will this approach register/unregister appropriately? Is anything bad design?
Will this cause any context leaks?
java android callback
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Description
The ActivityLifecycleHelper
uses wrap(Context)
to create the class and save a global Application
field. It then uses with(ActivityCallbacks)
to register android.app.Application.ActivityLifecycleCallbacks
on the Application
field. Whenever onActivityResumed(Activity)
is triggered the class calls a null OnSaved(Bundle)
. Whenever onActivitySaveInstanceState(Activity, Bundle)
is triggered the class calls a saved/null OnSaved(Bundle)
. It then unregisters the android.app.Application.ActivityLifecycleCallbacks
when onActivityDestroyed(Activity)
is triggered. Finally, it returns the base context of the Application
field.
ActivityLifecycleHelper.class
public class ActivityLifecycleHelper {
public interface ActivityCallbacks {
void OnSaved(Bundle savedInstance);
}
private final Application application;
private ActivityLifecycleHelper(Application application) {
this.application = application;
}
public static ActivityLifecycleHelper wrap(Context context) {
return new ActivityLifecycleHelper(assertApplication(context));
}
public Context with(final ActivityCallbacks callbacks) {
application.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity a, Bundle b) {}
@Override
public void onActivityStarted(Activity a) {}
@Override
public void onActivityResumed(Activity a) {
callbacks.OnSaved(null);
}
@Override
public void onActivityPaused(Activity a) {}
@Override
public void onActivityStopped(Activity a) {}
@Override
public void onActivitySaveInstanceState(Activity a, Bundle b) {
callbacks.OnSaved(b);
}
@Override
public void onActivityDestroyed(Activity a) {
application.unregisterActivityLifecycleCallbacks(this);
}
});
return application.getBaseContext();
}
private static Application assertApplication(Context context) {
final Context application = context.getApplicationContext();
if (application instanceof Application) return (Application) application;
throw new NullPointerException("Context must be instance of Application");
}
}
Usage
public class Usage implements ActivityLifecycleHelper.ActivityCallbacks {
private final Context context;
Usage(Context context) {
this.context = ActivityLifecycleHelper.wrap(context).with(this);
}
@Override
public void OnSaved(Bundle savedInstance) {
// doingit
}
}
Reasoning
This is used within a library that when initialized receives a context that will extend from an Application and hooks into any Activity LifeCycle events.
OnResume()
will allow the library to reset some things and onSaveInstanceState()
is so the library can rebuild.
Needed
Will this approach register/unregister appropriately? Is anything bad design?
Will this cause any context leaks?
java android callback
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
A minor suggestion, change theNullPointerException
thrown fromassertApplication(Context)
toIllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?
– Moses
Dec 18 '16 at 9:51
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19
add a comment |
Description
The ActivityLifecycleHelper
uses wrap(Context)
to create the class and save a global Application
field. It then uses with(ActivityCallbacks)
to register android.app.Application.ActivityLifecycleCallbacks
on the Application
field. Whenever onActivityResumed(Activity)
is triggered the class calls a null OnSaved(Bundle)
. Whenever onActivitySaveInstanceState(Activity, Bundle)
is triggered the class calls a saved/null OnSaved(Bundle)
. It then unregisters the android.app.Application.ActivityLifecycleCallbacks
when onActivityDestroyed(Activity)
is triggered. Finally, it returns the base context of the Application
field.
ActivityLifecycleHelper.class
public class ActivityLifecycleHelper {
public interface ActivityCallbacks {
void OnSaved(Bundle savedInstance);
}
private final Application application;
private ActivityLifecycleHelper(Application application) {
this.application = application;
}
public static ActivityLifecycleHelper wrap(Context context) {
return new ActivityLifecycleHelper(assertApplication(context));
}
public Context with(final ActivityCallbacks callbacks) {
application.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity a, Bundle b) {}
@Override
public void onActivityStarted(Activity a) {}
@Override
public void onActivityResumed(Activity a) {
callbacks.OnSaved(null);
}
@Override
public void onActivityPaused(Activity a) {}
@Override
public void onActivityStopped(Activity a) {}
@Override
public void onActivitySaveInstanceState(Activity a, Bundle b) {
callbacks.OnSaved(b);
}
@Override
public void onActivityDestroyed(Activity a) {
application.unregisterActivityLifecycleCallbacks(this);
}
});
return application.getBaseContext();
}
private static Application assertApplication(Context context) {
final Context application = context.getApplicationContext();
if (application instanceof Application) return (Application) application;
throw new NullPointerException("Context must be instance of Application");
}
}
Usage
public class Usage implements ActivityLifecycleHelper.ActivityCallbacks {
private final Context context;
Usage(Context context) {
this.context = ActivityLifecycleHelper.wrap(context).with(this);
}
@Override
public void OnSaved(Bundle savedInstance) {
// doingit
}
}
Reasoning
This is used within a library that when initialized receives a context that will extend from an Application and hooks into any Activity LifeCycle events.
OnResume()
will allow the library to reset some things and onSaveInstanceState()
is so the library can rebuild.
Needed
Will this approach register/unregister appropriately? Is anything bad design?
Will this cause any context leaks?
java android callback
Description
The ActivityLifecycleHelper
uses wrap(Context)
to create the class and save a global Application
field. It then uses with(ActivityCallbacks)
to register android.app.Application.ActivityLifecycleCallbacks
on the Application
field. Whenever onActivityResumed(Activity)
is triggered the class calls a null OnSaved(Bundle)
. Whenever onActivitySaveInstanceState(Activity, Bundle)
is triggered the class calls a saved/null OnSaved(Bundle)
. It then unregisters the android.app.Application.ActivityLifecycleCallbacks
when onActivityDestroyed(Activity)
is triggered. Finally, it returns the base context of the Application
field.
ActivityLifecycleHelper.class
public class ActivityLifecycleHelper {
public interface ActivityCallbacks {
void OnSaved(Bundle savedInstance);
}
private final Application application;
private ActivityLifecycleHelper(Application application) {
this.application = application;
}
public static ActivityLifecycleHelper wrap(Context context) {
return new ActivityLifecycleHelper(assertApplication(context));
}
public Context with(final ActivityCallbacks callbacks) {
application.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity a, Bundle b) {}
@Override
public void onActivityStarted(Activity a) {}
@Override
public void onActivityResumed(Activity a) {
callbacks.OnSaved(null);
}
@Override
public void onActivityPaused(Activity a) {}
@Override
public void onActivityStopped(Activity a) {}
@Override
public void onActivitySaveInstanceState(Activity a, Bundle b) {
callbacks.OnSaved(b);
}
@Override
public void onActivityDestroyed(Activity a) {
application.unregisterActivityLifecycleCallbacks(this);
}
});
return application.getBaseContext();
}
private static Application assertApplication(Context context) {
final Context application = context.getApplicationContext();
if (application instanceof Application) return (Application) application;
throw new NullPointerException("Context must be instance of Application");
}
}
Usage
public class Usage implements ActivityLifecycleHelper.ActivityCallbacks {
private final Context context;
Usage(Context context) {
this.context = ActivityLifecycleHelper.wrap(context).with(this);
}
@Override
public void OnSaved(Bundle savedInstance) {
// doingit
}
}
Reasoning
This is used within a library that when initialized receives a context that will extend from an Application and hooks into any Activity LifeCycle events.
OnResume()
will allow the library to reset some things and onSaveInstanceState()
is so the library can rebuild.
Needed
Will this approach register/unregister appropriately? Is anything bad design?
Will this cause any context leaks?
java android callback
java android callback
edited Jul 16 '17 at 19:38
Jamal♦
30.3k11116226
30.3k11116226
asked Nov 26 '16 at 21:43
Jon MerrittJon Merritt
713
713
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
A minor suggestion, change theNullPointerException
thrown fromassertApplication(Context)
toIllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?
– Moses
Dec 18 '16 at 9:51
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19
add a comment |
1
A minor suggestion, change theNullPointerException
thrown fromassertApplication(Context)
toIllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?
– Moses
Dec 18 '16 at 9:51
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19
1
1
A minor suggestion, change the
NullPointerException
thrown from assertApplication(Context)
to IllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?– Moses
Dec 18 '16 at 9:51
A minor suggestion, change the
NullPointerException
thrown from assertApplication(Context)
to IllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?– Moses
Dec 18 '16 at 9:51
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19
add a comment |
1 Answer
1
active
oldest
votes
Yes. It seems like a bad design or I would say not thought through given that you're building a library project which will be used by other apps.
First of all,
in your library initialization, you should ask for Application
reference rather than Context
reference.
For example,
if your library has an init method like this,
MyLibrary.init(Context applicationContext);
then it should be converted to accept Application
object like this,
MyLibrary.init(Application application);
Then,
inside that init
method, you should just register your class which is implementing Application.ActivityLifecycleCallbacks
.
application.registerActivityLifecycleCallbacks(ActivityLifecycleHelper.getInstance());
Make sure your class is a singleton
. In your example, your ActivityLifecycleHelper
class is not a singleton which is definitely a bad design pattern given that you're dealing with global level callbacks and want to initialize only once.
It might look like this,
public class ActivityLifecycleHelper implements Application.ActivityLifecycleCallbacks {
private static ActivityLifecycleHelper ourInstance = new ActivityLifecycleHelper();
private ActivityLifecycleHelper() {
}
public static ActivityLifecycleHelper getInstance() {
return ourInstance;
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
}
Also, I don't understand why you have two classes here. What's the use case of Usage
class ? Something seems wrong in this two class design.
I hope this helps. Let me know if you want me to elaborate anything.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f148202%2factivitylifecyclehelper-implementation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes. It seems like a bad design or I would say not thought through given that you're building a library project which will be used by other apps.
First of all,
in your library initialization, you should ask for Application
reference rather than Context
reference.
For example,
if your library has an init method like this,
MyLibrary.init(Context applicationContext);
then it should be converted to accept Application
object like this,
MyLibrary.init(Application application);
Then,
inside that init
method, you should just register your class which is implementing Application.ActivityLifecycleCallbacks
.
application.registerActivityLifecycleCallbacks(ActivityLifecycleHelper.getInstance());
Make sure your class is a singleton
. In your example, your ActivityLifecycleHelper
class is not a singleton which is definitely a bad design pattern given that you're dealing with global level callbacks and want to initialize only once.
It might look like this,
public class ActivityLifecycleHelper implements Application.ActivityLifecycleCallbacks {
private static ActivityLifecycleHelper ourInstance = new ActivityLifecycleHelper();
private ActivityLifecycleHelper() {
}
public static ActivityLifecycleHelper getInstance() {
return ourInstance;
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
}
Also, I don't understand why you have two classes here. What's the use case of Usage
class ? Something seems wrong in this two class design.
I hope this helps. Let me know if you want me to elaborate anything.
add a comment |
Yes. It seems like a bad design or I would say not thought through given that you're building a library project which will be used by other apps.
First of all,
in your library initialization, you should ask for Application
reference rather than Context
reference.
For example,
if your library has an init method like this,
MyLibrary.init(Context applicationContext);
then it should be converted to accept Application
object like this,
MyLibrary.init(Application application);
Then,
inside that init
method, you should just register your class which is implementing Application.ActivityLifecycleCallbacks
.
application.registerActivityLifecycleCallbacks(ActivityLifecycleHelper.getInstance());
Make sure your class is a singleton
. In your example, your ActivityLifecycleHelper
class is not a singleton which is definitely a bad design pattern given that you're dealing with global level callbacks and want to initialize only once.
It might look like this,
public class ActivityLifecycleHelper implements Application.ActivityLifecycleCallbacks {
private static ActivityLifecycleHelper ourInstance = new ActivityLifecycleHelper();
private ActivityLifecycleHelper() {
}
public static ActivityLifecycleHelper getInstance() {
return ourInstance;
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
}
Also, I don't understand why you have two classes here. What's the use case of Usage
class ? Something seems wrong in this two class design.
I hope this helps. Let me know if you want me to elaborate anything.
add a comment |
Yes. It seems like a bad design or I would say not thought through given that you're building a library project which will be used by other apps.
First of all,
in your library initialization, you should ask for Application
reference rather than Context
reference.
For example,
if your library has an init method like this,
MyLibrary.init(Context applicationContext);
then it should be converted to accept Application
object like this,
MyLibrary.init(Application application);
Then,
inside that init
method, you should just register your class which is implementing Application.ActivityLifecycleCallbacks
.
application.registerActivityLifecycleCallbacks(ActivityLifecycleHelper.getInstance());
Make sure your class is a singleton
. In your example, your ActivityLifecycleHelper
class is not a singleton which is definitely a bad design pattern given that you're dealing with global level callbacks and want to initialize only once.
It might look like this,
public class ActivityLifecycleHelper implements Application.ActivityLifecycleCallbacks {
private static ActivityLifecycleHelper ourInstance = new ActivityLifecycleHelper();
private ActivityLifecycleHelper() {
}
public static ActivityLifecycleHelper getInstance() {
return ourInstance;
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
}
Also, I don't understand why you have two classes here. What's the use case of Usage
class ? Something seems wrong in this two class design.
I hope this helps. Let me know if you want me to elaborate anything.
Yes. It seems like a bad design or I would say not thought through given that you're building a library project which will be used by other apps.
First of all,
in your library initialization, you should ask for Application
reference rather than Context
reference.
For example,
if your library has an init method like this,
MyLibrary.init(Context applicationContext);
then it should be converted to accept Application
object like this,
MyLibrary.init(Application application);
Then,
inside that init
method, you should just register your class which is implementing Application.ActivityLifecycleCallbacks
.
application.registerActivityLifecycleCallbacks(ActivityLifecycleHelper.getInstance());
Make sure your class is a singleton
. In your example, your ActivityLifecycleHelper
class is not a singleton which is definitely a bad design pattern given that you're dealing with global level callbacks and want to initialize only once.
It might look like this,
public class ActivityLifecycleHelper implements Application.ActivityLifecycleCallbacks {
private static ActivityLifecycleHelper ourInstance = new ActivityLifecycleHelper();
private ActivityLifecycleHelper() {
}
public static ActivityLifecycleHelper getInstance() {
return ourInstance;
}
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
}
Also, I don't understand why you have two classes here. What's the use case of Usage
class ? Something seems wrong in this two class design.
I hope this helps. Let me know if you want me to elaborate anything.
answered Jan 17 '17 at 14:28
Jabbar_JigariyoJabbar_Jigariyo
22414
22414
add a comment |
add a comment |
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f148202%2factivitylifecyclehelper-implementation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
A minor suggestion, change the
NullPointerException
thrown fromassertApplication(Context)
toIllegalArgumentException
. Other than that I don't fully understand what you're asking, perhaps you could edit the question to make it clearer?– Moses
Dec 18 '16 at 9:51
Thank you for your suggestion. I just was looking for some validation, I'm still new and have a weak knowledge base. Basically wanted to make sure the code would be acceptable to those more educated than myself.
– Jon Merritt
Dec 18 '16 at 12:19