The title is probably not the best but I will try to explain my problem.
I have a login/signup page where I can click on a facebook button to login through or I can click on a mail button.
When I click on this button, I open a new activity with a form to sign up. I want this activity to be transparent to a certain extent to see my first login/signup in the background page which is done. On this same page (sign up page), I have another button "I already have an account" that opens a new login activity.
This login activity is also transparent but the background is the sign up form and not my first page which is normal but I don't know how to get my first page as a background.
Any advice ?
Regards,
Arnaud
You just need to call finish()
Intent intent = new Intent(this, NextActivity.class);
startActivity(intent);
finish();
Call finish() when you move to your signin page. This'll finish the signup form and the first page will show up as your background.
Related
I have 4 activities as activity1, activity2, activity3, and activity4.
I access these activities from main activity which has four buttons, each button opens a specific activity, for example button1 opens activity1 through an intent.
In these four activities I have a method which checks to see if user is logged in to firebase or not, if user is not logged the login activity opens. So here comes my problem:
When the user clicks the login button, i want him to be directed to the intended activity.
If for example he wants to open activity1, but then directed back to login activity, when he logs in he should go to activity1,
Under onclick listerner of the login button i have this intent:
Intent intent = new Intent(Login.this, activity1.class);
startActivity(intent)
This works when user actually whats to go to activity1, what if he wants to go to any other activity?
I have this sign in/register page. When you log in, it will go to membership page(fragment) and now I want to go back to the home page of the phone without logging out but whenever I click back built in button it goes to the past page activities.
I tried this android:noHistory="true" but when i click sign in but i didnt sign in, just backstack. the sign in/register page not appearing anymore.
If you would never like to navigate back to the login activity simply use the line of code
finish();
after your call to startAcitivty(). This will close the activity and won't be available to navigate back to without restarting the app or specifically calling the activity later in your code.
Or just Override onBackPressed() to finish.
Android system's default photo viewing app is used as the default viewer. It functions normally.
The code for photo viewing button is as follows:
//view source image
public void viewSourceClicked(View view){
Uri uri = getImageUri(this, MethodCommons.convertByteArrayToBitmap(itemToBeEdited.getOriginalImage()));
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
}
Except, when viewer's share button is pressed showing the share menu, if the user presses power button (closes the screen), then clicking this button after resuming the activity results only in a black screen.
Restarting the app containing the photo-viewing button does not resolve the issue.
This black screen can only be resolved by opening the default photo viewing app and click the share button once. So I figure that it relates to photo viewer's share activity being left open somehow.
How to prevent such black screen from occurring? any other suggestions?
Eventually I figured out that this resulted from using MediaStore.Images.Media.insertImage.
Using FileProvider in place of insertImage solved the problem.
I have developed a simple android application which user have to login with a login page and he will be redirect to the home page.But my problem is when i press back button from the home page it again redirected to the login page .But I don't want to see the login page.I want to exit from the application when the back button is pressed from the home page.How can i do this.Can someone help me.
Call finish in your login activity before you start your home activity. You cannot return to a finished activity
In LoginPageActivity call finish() after starting Intent with HomePageActivity so the LoginPage wont be held in back stack
public void startHomeActivity() {
startActivity(new Intent(LoginActivity.this, HomeActivity.class);
finish();
}
In the login activity call finish() just after starting the Intent that redirect to the home page. Calling finish only if the login in completed correctly, remove the current login activity from the android stack and the new home activity will be proposed to the user.
startActivity(new Intent(this, newactivity.class);
finish();
Give a look to the activity lifecycle
Do this to start your HomeActivity from your LoginActivity
startActivity(new Intent(this, HomeActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP));
I'm currently doing a Widget in Android. It is on the market and it's free.
I want to surprise the users by let them choose a picture they want to show in the widget.
Now...
If the widget is clicked, a PreferenceActivity appears. <-- Works!
In this Activity the user should be able to choose a picture from the phone picture gallery. <-- HOWTO?
After the User selected the prefered picture, the picture path or the drawable object should be stored in the SharedPreferences. <-- Would be really nice!
Is there any solution?
Thx!
In order to get an image from the Gallery, you must send an intent to start up the Gallery for the user to choose an image as such
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, 10);
This will start the gallery and will call onActivityResult within your activity.