I know this question has been asked many times but hear me out. I have MainActivity which is a LoginActivity & it uses facebook login and AccountKit From Facebook to login and start next activity which is a ContactsActivity. When i am in ContactsActivity and press back button it takes me to MainActivity but i want to close the application as user has successfully logined in and if the user again opens the app it should open ContactsActivity directly as user has signed in successfully previously.
Problem is when i press Back button in Contacts Activity,it takes me to LoginActivity,i already tried finish() after startActivity(intent) which closes my app and not takes me to ContactsActivity after successfull signin.If i open my app again then it takes me directly to ContactsActivity.
I even tried onBackPressed in which i wrote finish but it doesnt work.
In Android Manifest also i wrote android:noHistory="true" in MainActivity tag but it doesn't work.
Please help
activity_main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="pritish.sawant.com.simplychat.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/loginwithphonenumber"
android:text="#string/loginwithphoneno"
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:textColor="#android:color/white"
android:background="#drawable/login_button_selector"
android:textSize="16sp"
android:layout_centerInParent="true"
android:textAlignment="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/email_login_button"
android:text="#string/loginwithemail"
android:layout_below="#+id/loginwithphonenumber"
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:textColor="#android:color/white"
android:background="#drawable/login_button_selector"
android:textSize="16sp"
android:textAlignment="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
/>
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/email_login_button"
android:textSize="16sp"
android:textAllCaps="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:paddingTop="14dp"
android:paddingBottom="14dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
/>
</RelativeLayout>
MainActivity
public class MainActivity extends AppCompatActivity {
public static int APP_REQUEST_CODE=1;
private LoginButton facebookloginButton;
private Button emailloginbutton,phonenologinbutton;
private CallbackManager callbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
facebookloginButton=(LoginButton)findViewById(R.id.facebook_login_button);
emailloginbutton=(Button)findViewById(R.id.email_login_button);
phonenologinbutton=(Button)findViewById(R.id.loginwithphonenumber);
callbackManager=CallbackManager.Factory.create();
facebookloginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
launchContactsActivity();
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
Toast.makeText(getApplicationContext(), R.string.loginfailed,Toast.LENGTH_LONG).show();
}
});
AccessToken accessToken= AccountKit.getCurrentAccessToken();
com.facebook.AccessToken loginToken= com.facebook.AccessToken.getCurrentAccessToken();
if(accessToken!=null || loginToken!=null){
launchContactsActivity();
}
emailloginbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onLogin(LoginType.EMAIL);
}
});
phonenologinbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onLogin(LoginType.PHONE);
}
});
}
private void launchContactsActivity(){
Intent intent=new Intent(getApplicationContext(),ContactsActivity.class);
startActivity(intent);
finish();
}
private void onLogin(final LoginType loginType) {
// create intent for the Account Kit activity
final Intent intent = new Intent(this, AccountKitActivity.class);
// configure login type and response type
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
loginType,
AccountKitActivity.ResponseType.TOKEN
);
final AccountKitConfiguration configuration = configurationBuilder.build();
// launch the Account Kit activity
intent.putExtra(AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configuration);
startActivityForResult(intent, APP_REQUEST_CODE);
finish();
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode,resultCode,data);
if(requestCode==APP_REQUEST_CODE){
AccountKitLoginResult accountKitLoginResult=data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
if(accountKitLoginResult.getError()!=null){
String toastMessage = accountKitLoginResult.getError().getErrorType().getMessage();
Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show();
} else if (accountKitLoginResult.getAccessToken() != null) {
launchContactsActivity();
}
}
}
}
In normal way you shouldn't close app - user will moves it to back by pressing home or closing your activities by pressing back.
But you can use this tips:
1) Close old activities after starting the new ones if they not needed in back stack:
startActivity(newActivityIntent);
finish();
The override onBackPressed and the app will close
2) You can move task to back (instead of close) if you need http://developer.android.com/reference/android/app/Activity.html#moveTaskToBack(boolean)
Related
I was working yesterday and not today. Have two buttons one to go back, one that is an emergency button that calls a method to open the dialer for a call to the ambulance.
I think it may be an XML problem not sure was working fine now unresponsive maybe I changed something I shouldn't have. When it was clicking earlier it was saying the method could not be found which I just don't get it as it is in the correct file
ReportActivity.java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//allows for a smoother transition
overridePendingTransition(0, 0);
setContentView(R.layout.activity_report);
EditText incidentReport = this.findViewById(R.id.Incident_Report);
incidentReport.setSelection(0);
try {
back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(ReportActivity.this, MainActivity.class);
startActivity(intent);
}
});
} catch (NullPointerException n) {
Toast.makeText(this, "Error,", Toast.LENGTH_LONG);
}
try {
emergency.setOnClickListener(new View.OnClickListener() {
public void onClick(#NonNull View v) {
Intent call = new Intent(ReportActivity.this, CallActivity.class);
startActivity(call);
}
});
} catch (NullPointerException n) {
Toast.makeText(this, "Error,", Toast.LENGTH_LONG);
}
}
#Override
public void onClick(View v) {
}
private boolean checkPermission(String permission) {
int permissionCheck = ContextCompat.checkSelfPermission(this, permission);
return (permissionCheck == PackageManager.PERMISSION_GRANTED);
}
public void call(View view) {
if (checkPermission("android.permission.CALL_PHONE")) {
Intent call = new Intent(Intent.ACTION_DIAL);
String number = "tel:" + getString(R.string.phone_number);
call.setData(Uri.parse(number));
startActivity(call);
}
}
}
activity_report.xml
android:gravity="start"
android:hint="#string/Hint"
android:inputType="text"
android:textAlignment="textStart"
android:textCursorDrawable="#drawable/color_cursor"
app:layout_constraintBottom_toTopOf="#+id/submit_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/submit_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginLeft="80dp"
android:layout_marginTop="32dp"
android:background="#drawable/yes_button"
android:text="Submit"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Incident_Report" />
<Button
android:id="#+id/back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginEnd="80dp"
android:layout_marginRight="80dp"
android:background="#drawable/diagnose_button"
android:onClick="onClick"
android:text="Back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Incident_Report" />
<Button
android:id="#+id/emergency_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="131dp"
android:layout_marginBottom="106dp"
android:background="#drawable/no_button"
android:onClick="call"
android:text="EMERGENCY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/submit_btn" />
</androidx.constraintlayout.widget.ConstraintLayout>
If you plan on using android:onClick="call"in your xml then you should also have a corresponding function called callin your activity and the logic to perform the click goes inside it.
If you plan on extending the View.onClickListener then inside your override void onClick() you can have a switch statement of your button ids and perform your logic
alternatively you can ignore the first two and get the id of the button and implement the click logic inside the onCreate()
I have 2 activities that involved in this question:
LoginActivity: A Login in Screen (called by a subclass of Activity Class)
Updater Activity: A Update Screen that show updating progress when new app version is availble (called by a subclass of Application Class)
This is what I want:
When the app FIRST LAUNCH, and if new version of the app is available, the UPDATER ACTIVITY should be on top of every activity include the Login Activity,
so it will be the first screen user see during first launch of the app.
only after the updating progress is done, the UPDATER ACTIVITY will be dismissed then Login Screen be on top.
However this is what actually happened:
The LOGIN ACTIVITY always on top of UPDATER ACTIVITY...
My Guess is that since the UPDATER ACTIVITY is called By APPLICATION CLASS's subClass, and the LOGINACTIVITY is called by an ACTIVITY CLASS sub class,
the Application class's method such as OnResume always get called before Activity onCreate Method, thus the LOGINACTIVITY always appear on top of UPDATER ACTIVITY,
I just wondering if there is anyway I could make my UPDATER ACTIVITY be on top of any activities including the LOGIN ACTIVITY?
//LoginActivity involved
public abstract ClassA extends Activity {
.....
.....
protected void onResume() {
super.onResume();
.....
if(isAuthenticated){
Intent intent = new Intent(this, LoginActivity.class)
.putExtra(...)
startActivityForResult(intent, XXX);
}
}
}
====
//Updater Activity involved
public abstract class ClassB extends Application {
....
....
....
public void onCreate() {
super.onCreate();
Intent updaterIntent = new Intent(this, UpdaterActivity.class);
updaterIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(updaterIntent);
}
}
i have diffrent solution instent of activity create dialog box activity.
public class ViewDialog {
public void showDialog(Activity activity, String msg){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
dialog.setContentView(R.layout.updatedialog);
TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
text.setText(msg);
Button dialogUpdate = (Button) dialog.findViewById(R.id.update);
Button dialogcancel = (Button) dialog.findViewById(R.id.cancel);
Button dialogremindme = (Button) dialog.findViewById(R.id.remindeme);
TextView textView= (TextView) dialog.findViewById(R.id.machhint1);
TextView textView2= (TextView) dialog.findViewById(R.id.machhint2);
textView2.setText("Your old version is : "+versionName);
textView.setText("Current version in playstore : "+version);
dialogcancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialogUpdate.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
SharedPreferences.Editor editoradddetail1 = getSharedPreferences("later", MODE_PRIVATE).edit();
editoradddetail1.putString("days", "");
editoradddetail1.commit();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
later="";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
dialog.dismiss();
}
});
dialogremindme.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
SharedPreferences.Editor editoradddetail1 = getSharedPreferences("later", MODE_PRIVATE).edit();
Date someDate = new Date(); // Or whatever
Date dayAfter = new Date(someDate.getTime() + TimeUnit.DAYS.toMillis( 2 ));
DateFormat dateFormat=new SimpleDateFormat("dd/MM/yyyy");
String formattedDate=dateFormat.format(dayAfter);
editoradddetail1.putString("days", formattedDate);
editoradddetail1.commit();
dialog.dismiss();
}
});
dialog.show();
}
}
//and xml is.
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="250dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="250dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:id="#+id/main"
android:background="#FFed6904"
android:layout_height="120dp">
<TextView
android:id="#+id/machhint"
android:text="Note:- Your current Version Did Not Match"
android:layout_width="match_parent"
android:textColor="#color/white"
android:textSize="13dp"
android:layout_height="60dp" />
<TextView
android:id="#+id/machhint1"
android:text="preschool version is"
android:layout_width="wrap_content"
android:textSize="13dp"
android:textColor="#color/white"
android:layout_below="#+id/machhint"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/machhint2"
android:text="Your Vertion is :"
android:layout_width="wrap_content"
android:textColor="#color/white"
android:textSize="13dp"
android:layout_below="#+id/machhint1"
android:layout_height="30dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:id="#+id/text1"
android:layout_below="#+id/main"
android:layout_height="40dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXTO"
android:id="#+id/text_dialog"
android:layout_marginTop="3dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="3dp"
android:textSize="18sp"
android:textColor="#ff000000"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_below="#+id/text1"
android:gravity="center_vertical|center_horizontal"
android:layout_height="55dp">
<Button
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="Update"
android:id="#+id/update"
android:gravity="center"
android:layout_toLeftOf="#+id/remindeme"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="Later"
android:id="#+id/remindeme"
android:gravity="center"
android:layout_centerHorizontal="true"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="Cancel"
android:id="#+id/cancel"
android:gravity="center"
android:layout_toRightOf="#+id/remindeme"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
I have a form to be filled by user and next button "Next" in Activity1.
When user clicks "Next" button second activity Activity2 is started.
In Activity2 i have previous button "Previous".(* not device back button)
So when user clicks " Previous" button, Activity1 should be opened with the entered details in the form.
Activity1 should not be refreshed.
Seached alot on stackoverflow but no luck..!!!
Why don't you use startActivityForResults and then in the started activity finish()
In the started activity you have access to your intent in the onCreate method getIntent(); then you can use setResult(Activity.RESULT_OK, result); or setResult(Activity.RESULT_OK); (For canceled Activity.RESULT_CANCELED) to return result code and data and after you set the result you call finish and then return (code doesn't exit the methods if I remember correctly).
Then in the first activity you get the result and handle what to do with it in:
onActivityResult(int requestCode, int resultCode, Intent data)
Another option:
You could also use the logic for back button pressed calling the method from your code: super.onBackPressed();
Edit
As I promised here's an Example
Two activities - first one have two TextViews and a button next that launches the second activity -> in the second activity two EditTexts in which you enter some data which is then returned to the first activity when you press previous button. If you press back button instead of previous button, you enter in the canceled logic which is not doing anything in the example there is only a comment.
MainActivity
TextView textViewFirstName;
TextView textViewFamilyName;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewFirstName = (TextView)findViewById(R.id.first_name_edit_text);
textViewFamilyName = (TextView)findViewById(R.id.family_name_edit_text);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//requestCode here is 12345 that we passed when we started SecondActivity
if(resultCode == Activity.RESULT_OK){
String resultFirstName = data.getStringExtra("firstName");
String resultFamilyName = data.getStringExtra("familyName");
textViewFirstName.setText(resultFirstName);
textViewFamilyName.setText(resultFamilyName);
}
if (resultCode == Activity.RESULT_CANCELED) {
//Canceled logic
}
}
public void nextButtonClick(View view) {
Intent i = new Intent(view.getContext(), SecondActivity.class);
//If you want you could pass some additional data, like which action to take
//if you're reusing the second activity for more than one use case
i.putExtra("someAdditionalData", "Some string that you want to pass");
//12345 is int that you pass and will be returned as requestCode in onActivityResult
startActivityForResult(i, 12345);
}
SecondActivity
EditText editTextFirstName;
EditText editTextFamilyName;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
editTextFirstName = (EditText)findViewById(R.id.first_name_edit_text);
editTextFamilyName = (EditText)findViewById(R.id.family_name_edit_text);
Bundle bundle = getIntent().getExtras();
String someAdditionalData = bundle.getString("someAdditionalData");
}
public void previousButtonClick(View view) {
Intent returnIntent = new Intent();
returnIntent.putExtra("firstName", editTextFirstName.getText().toString());
returnIntent.putExtra("familyName", editTextFamilyName.getText().toString());
setResult(RESULT_OK, returnIntent);
finish();
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:text="Main"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:hint="First name"
android:id="#+id/first_name_edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:hint="Family name"
android:id="#+id/family_name_edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<Button
android:onClick="nextButtonClick"
android:text="Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
second_activity.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SecondActivity">
<TextView
android:text="Second"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:hint="First name"
android:id="#+id/first_name_edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:hint="Family name"
android:id="#+id/family_name_edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<Button
android:onClick="previousButtonClick"
android:text="Previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
On previousButton onClickListener you can call finish();
This will close the current activity and reload the previous one from the stack. This is a quick hack.
Try overriding onBackPressed method inside second activity and call it on click event of previous button
Inside Activity 2
#Override
public void onBackPressed()
{
super.onBackPressed();
}
And call this on previous button click event
buttonPrevious.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
onBackPressed();
}
});
I would refrain from using finish(); cuz it kills the activity from where it's called. Try to use:
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
instead of finish();
I'm trying to implement Google+ authentication for my Android app, but the sign in button just doesn't work.
My onClick method in SignInActivity. I also tested the same with a normal button.
public void onClick(View view) {
if (view.getId() == R.id.sign_in_button){
Toast.makeText(this, "Log in pressed", Toast.LENGTH_SHORT).show();
}
if (view.getId() == R.id.button1) {
Toast.makeText(this, "Log in pressed", Toast.LENGTH_SHORT).show();
mGoogleApiClient.connect();
}
}
XML showing button properties.
<com.google.android.gms.common.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_in_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="49dp"
android:onClick="onClick"
android:text="Button" />
When I press the normal button the toast appears just fine and authentication works, but when I press the g+ button nothing happens..
Seems you need give the onClickListener to your SignIn Button. Something like that
public class YourActivity extends Activity implements View.OnClickListener{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yourlayout);
//You probably miss this line:
this.findViewById(R.id.sign_in_button).setOnClickListener(this);
this.findViewById(R.id.button1).setOnClickListener(this);
}
public void onClick(View view) {
// Your stuff...
}
}
This should work:
Go to the Google Developer Console and enable Google+ API.
I am trying to open an activity which will cover half screen on Home Scree.
It will be called by BroadcastReceiver which will be triggered when call ends.
Problem I am facing is it opens the MAIN activity in the background and I am not able to get Home Screen.
Here is the code:
public class IncomingCallInterceptor extends BroadcastReceiver { // 1
#Override
public void onReceive(Context context, Intent intent) { // 2
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); // 3
if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) { // 4
Intent intent_new=new Intent(context, HalfScreen.class);
intent_new.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent_new.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent_new);
}
}
}
Activity Class:
public class AddAppointmentHomeScreenActivity extends Activity {
#Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.add_appointment_home_screen_activity);
}
}
add_appointment_home_screen_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:windowAnimationStyle="#android:style/Animation.Translucent"
android:windowBackground="#android:color/transparent"
android:windowIsTranslucent="true"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="24dp"
android:layout_marginLeft="72dp"
android:text="Button" />
</RelativeLayout>
Manifest File:
<activity android:name=".AddAppointmentHomeScreenActivity" ></activity>
Please let me know if more details are required..
public class AddAppointmentHomeScreenActivity extends Activity {
#Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.add_appointment_home_screen_activity);
}
}