I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static RestAdapter mInstance = null;
public static RestAdapter getInstance(){
if(mInstance == null)
{
mInstance = new RestAdapter.Builder().setEndpoint(BASE_URL).build().create(RestClient.class);
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static RestAdapter mInstance = null;
public static RestAdapter getInstance(){
if(mInstance == null)
{
mInstance = new RestAdapter.Builder().setEndpoint(BASE_URL).build().create(RestClient.class);
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static RestAdapter mInstance = null;
public static RestAdapter getInstance(){
if(mInstance == null)
{
mInstance = new RestAdapter.Builder().setEndpoint(BASE_URL).build().create(RestClient.class);
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static SingletonRestAdapterRestAdapter mInstance = null;
private Singleton(){
// do what's needed to initialize the RestAdapter here
}
public static SingletonRestAdapter getInstance(){
if(mInstance == null)
{
mInstance = new SingletonRestAdapterRestAdapter.Builder().setEndpoint(BASE_URL).build().create(RestClient.class);
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static SingletonRestAdapter mInstance = null;
private Singleton(){
// do what's needed to initialize the RestAdapter here
}
public static Singleton getInstance(){
if(mInstance == null)
{
mInstance = new SingletonRestAdapter();
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static RestAdapter mInstance = null;
public static RestAdapter getInstance(){
if(mInstance == null)
{
mInstance = new RestAdapter.Builder().setEndpoint(BASE_URL).build().create(RestClient.class);
}
return mInstance;
}
}
I don't think you need all other Activities to extend BaseActivity
, though that is one way to do it. What you're looking to do is make your RestAdapter
a singleton, which can be implemented by having some static singleton class for wrapping your RestAdapter
.
Here's an example of what that might look like, which was adapted from Akylah's answer which referred to this gist of a sample singleton:
public class SingletonRestAdapter {
private static SingletonRestAdapter mInstance = null;
private Singleton(){
// do what's needed to initialize the RestAdapter here
}
public static Singleton getInstance(){
if(mInstance == null)
{
mInstance = new SingletonRestAdapter();
}
return mInstance;
}
}