last day (14 days later) » 

10:06 AM
0
A: Check whether an activity is active or not from a different activity

Raviwhen user login finish login activity and start home activity. when user logout finish home activity and start login activity

 
I wish I could do that. I tried it, actually I am using a custom theme in my app, the theme also has a customized action bar, if I finish the activity and call another intent, then the transition is showing up a black action bar for a split second which will be a very bad user experience.
 
1st start activity and than finish current activity, this want show blank action bar. try it
 
ok let me try. I will update you.
Hey friend, its not showing the action bar but its stacking the login activity
 
when u move from login to home just finish login activity, and when you logout just finish home activity and start login activity, it will work
 
I can not do that, because, there are certain activities and services dependent on the login activity, finishing it would sink the whole ship!
 
10:06 AM
Than last way is to make object of activity.
 
please elaborate
 
Make object of LoginActivity.
LoginActivity activity;
than in oncreate write activity=this;
and when user logout check whether LoginActivity.activity==null
if its null than start loginactivity else finish current activity
make public static object like public static LoginActivity activity;
 
so...........the object will be made in the login activity itself
and LoginActivity.activity==null will be checked when the logout button is clicked right?
 
yes
 
ok let me implement that
I will tell you about the output
ok?
 
10:12 AM
ok
 
one thing
 
yes tell
 
in case the login activity is never opened
ie if the user is an existing user
 
than LoginActivity.activity will be null
check for possibilities
 
then will the LoginActivity.activity==null cause an error?
 
10:13 AM
nop
 
ok
 
it will not
 
let me check
I did something like : if (LoginActivity.activity==null) {
			Intent i = new Intent(mContext, HomeActivity.class);
			getActivity().startActivity(i);
			getActivity().finish();
		}
		else {
			getActivity().finish();
		}
its not stacking anymore
but if the loginactivity is kipped then the app is exiting if back is pressed from home activity
 
than u can do coding for back button
 
if (LoginActivity.activity==null) {
Intent i = new Intent(mContext, LoginActivity.class);
getActivity().startActivity(i);
getActivity().finish();
}
else {
getActivity().finish();
}
this is back button
 
10:26 AM
when user press back button u dont need to move to login ri8?
 
from where?
 
from home activity
 
no
dont need to
 
than on back button just check if activity==null
 
I need to ony move to login if the user presses logout
 
10:28 AM
than finish() current activity
 
which screen back button?
 
home screen back button
if activity!=null than finish() current as well as use Loginactivity.activity.finish()
 
firstly, the user will not use back button on home scree
secondly in homescreen the user can exit the app on double tapping back button
so how can that kill the login activity?
 
when user double tap, that means its exit
just finish login activity there
 
I will not be able to do that my dear
think of this
suppose u are a first time user
you login to the app
u do not like the app
on the home screen there is the logout button
you click it
and you land to the login screen
situation 2
you are an old user
you wanna log out
you click on the logout button, and you are redirected back to the login screen
 
10:34 AM
ok
so where is confusion for you?
 
the back button on the home screen is only used when you want to exit the app thats it
you want me to finish the login activity in back button of the home screen
 
nop not like that
suppose
 
now the thing is that, the user may not use the back button in the home screen but still like to logout
 
i am first time user
login to app
and than pressing back button on home screen than what will happen?
 
it will just exit the app if you double press the back button on the home screen
 
10:37 AM
ok and when i enter again in app, home screen will apear
ri8?
 
yes the login screen will be skipped
 
yes thats what i m teeling u, when user press back button that means exit
just check whether login activity is in stack or not
 
yes
 
if it is there than finish
 
its never stacking there
I have checked it
 
10:39 AM
than no need to write backbutton code
 
yes
what I want to do now is that
if the login screen does not open
and the user logs out the app
then he is thrown out of the app
 
nop, on logout button click
 
he is not redirected to the login screen
 
just check for loginactivity.activity==null
 
yes
 
10:41 AM
if it is null, start login activity
 
yeah thats what I did
I pasted the code here
do yo wanna see that again?
 
if (LoginActivity.activity==null) {
Intent i = new Intent(mContext, HomeActivity.class);
getActivity().startActivity(i);
getActivity().finish();
}
else {
getActivity().finish();
}
this u have written in logout click??
 
yes
 
Intent i = new Intent(mContext, LoginACtivity.class);
change it\
 
only HomeActivity.class will be LoginActivity.class
 
10:42 AM
yes
than it will work
 
yeah I had already changed it
 
coz just now i did same thing
 
I pasted it wrong here
but its not working
 
can u upload both class here?
 
both class?
 
10:43 AM
login and home
 
there are some more activities in between
I guess it will be difficult for you like that
 
just give me login and home
i'l understand it
no probs
 
ok
then in real like the login activity is actually called the homeactivity
and the homeactivity is called the studystorymain
ok?
 
ok
 
the studystory main has a freagment called settings
that fragment has a logout button
understood?
 
10:46 AM
yes
 
public class HomeActivity extends Activity {

private EditText studentNameEdittext;
private Button startYourStoryButton, loginButton, navitasCollegesButton, settingsButton, search_friends_button, browseStoriesButton;
private TextView textView1;

public static HomeActivity activity;

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
if (getFromPreference("loginStatus").equalsIgnoreCase("true")) {
finish();
saveInPreference("loginStatus", "");
the home activity
above
public class SettingsFragment extends Fragment {

private ToggleButton postStoryOnFBSwitch;
private Button termsPolicy;
private RelativeLayout logoutFrame;
private View myView;
private Context mContext;
private ImageView logoutImg;
private TextView logoutTxt;

public SettingsFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_settings, container, false);

myView = view;
mContext = myView.getContext();
the above is the fragment under the studystorymain
 
ok
 
but I hope the other registration activities will not be required
as they are opened and closed properly
and is not stacking
so for new users home does not appear
only study story main appears
for new users home as well as study story main appears
got it?
 
so home is your login ri8?
and study is your home
 
yes
my friend
 
10:54 AM
ok
do you have splash screen before homeActivity?
 
yeah
 
than u should check your shared preference in splash
dont use it in home activity onstart or on resume
 
public class SplashScreenActivity extends Activity {
// private GoogleMap map;
// private MapView mapview;

private ImageView staticHtpTest;
// private Button gotoYourStory, gotoSignUp;
private String facebookId;
private static String LOG_TAG = "SplashScreenActivity";

// Contstuctor that starts the uri call

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);

checkIfRoot();

assignSessionVaraiable();
splash screen'
 
so you r using loginType to check whether user is new or not?
u can check loginStatus there
if its true move to study
else move to home
 
that is done in splash screen
 
11:04 AM
there is some thing els
because u r moving to home
but its finishing
try to put log in home screen and check whether its moving or not
 
moving?
didnt get u!
 
put log in onstart onresume and oncreate of home
and than try to logout
check whether that log is printed or not
 
somehow its managing to stack!
if I use the splash screen checking
private void checkIfUserIsLoggedIntoParseAlready(){
Log.e("Activtiy Main2", "ERROR RUNNIN");
ParseUser user = ParseUser.getCurrentUser();

Log.e("Activtiy Main3", "ERROR RUNNIN" + user);
Log.e("Testing the Parse User Object Id", " " + user.getObjectId());
if (user.getObjectId() != null) {
ParseUser.getCurrentUser();
ParseUser.logOut();
saveInPreference("loginStatus", "");
// Check if its a facebook user too
Intent i = new Intent(mContext, HomeActivity.class);
getActivity().startActivity(i);
getActivity().finish();
 
ok
so its working or not?
 
11:24 AM
nope
stacks
you may comment
I have to go for now
please leave comments what tou think
I will catch up tomorrow
 
i think its complicated
 
thanks for your time
yes it is very complicated
 
thing is easy but i guess coding is making me confuze
 
its a very big app
 
thats not a big deal\
 
11:26 AM
and it has a total no of say 60 activities
you can take a close look at it
 
ok
office time over?
 
I broke my head over it throughout the day
yup over
 
ok
 
byee
 
lucky girl
its just 5PM
ok bye
 
11:27 AM
not girl
boy
I work 9 to 5
hahaha
 
ok ok sorry
lucky boy
 
its ok my friend
see you soon
please tell me if you figure out anything
an upvote for your time!
 

last day (14 days later) »