所以我现在做了一个应用程序,我使用侧菜单来实现一些功能,比如注销,设置等。当用户需要注销时,我不得不将他重定向到LoginActivity,出于某种原因,它只是关闭侧菜单,就像没有那个项目一样。我在这里和youtube上都找过类似的问题,但没有任何帮助。而且,当按下侧菜单上的“logout_btn”时,该应用程序似乎没有错误
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private BottomNavigationView bottomNav;
private DrawerLayout root;
private Toolbar toolbar;
private TextView report_btn;
private NavigationView navigationView;
private String[] permissions;
private LocationManager locationManager;
private FirebaseAuth mAuth;
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()){
case R.id.logout_btn:
mAuth.signOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
break;
}
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Making sure no data are left
ServiceSharedInfo.deleteALlData();
mAuth = FirebaseAuth.getInstance();
//Setting values
FirebaseUser user = mAuth.getCurrentUser();
if(user == null){
startActivity(new Intent(MainActivity.this, LoginActivity.class));
}else{
System.out.println("#~#~#~#~#~#~# User: "+ user.getEmail());
}
permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.INTERNET};
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
root = findViewById(R.id.root_layout);
toolbar = findViewById(R.id.main_tool_bar);
navigationView = findViewById(R.id.side_nav);
bottomNav = findViewById(R.id.bottom_navigation);
bottomNav.setOnNavigationItemSelectedListener(navListener);
report_btn = findViewById(R.id.report_btn);
setSupportActionBar(toolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(MainActivity.this,
root,toolbar,R.string.navigation_open,
R.string.navigation_close);
root.addDrawerListener(toggle);
toggle.syncState();
getSupportFragmentManager().beginTransaction().replace(R.id.container_layout,
new HomeFragment()).commit();
bottomNav.getMenu().getItem(1).setChecked(true);
report_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"someemil@email.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "<-Your subject here->");
emailIntent.putExtra(Intent.EXTRA_TEXT, "<-Your Problem here->");
startActivity(Intent.createChooser(emailIntent,"Send mail..."));
}
});
navigationView.setNavigationItemSelectedListener(this::onNavigationItemSelected);
}
private BottomNavigationView.OnNavigationItemSelectedListener navListener =
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment fragmentSelected = null;
switch(item.getItemId()){
case R.id.home_nav:
fragmentSelected = new HomeFragment();
break;
case R.id.installation_nav:
fragmentSelected = new InstallationFragment();
break;
case R.id.damage_nav:
fragmentSelected = new DamageFragment();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.container_layout,
fragmentSelected).commit();
return true;
}
};
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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"
tools:context=".MainActivity"
android:id="@+id/root_layout"
android:fitsSystemWindows="true">
<com.google.android.material.navigation.NavigationView
android:id="@+id/side_nav"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/menu_header"
app:menu="@menu/side_nav_menu"
tools:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:id="@+id/appBar">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/main_tool_bar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:src="@drawable/somephoto" />
<TextView
android:id="@+id/report_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:drawableStart="@drawable/ic_baseline_priority_high_24" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_navigation"
android:layout_below="@id/appBar" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:clickable="false"
app:menu="@menu/button_navigation" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
side_nav_menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group>
<item
android:id="@+id/logout_btn"
android:title="Log out :("
android:icon="@drawable/ic_baseline_exit_to_app_24"/>
</group>
</menu>
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if (item.getTitle().equals("Log out :(")) {
mAuth.signOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
return false;
}
}
这对我有用..
试试这个...
我有一个订单按钮应该是重定向用户到购物车页面与订购的项目 这是网上的路线。php 这是函数addToCart 但是当我点击按钮时,它不会重定向到购物车页面,它会一直加载到我所做的同一个位置 在函数上,它输出正确的结果
我有一个sidR菜单,内容如下: 每个页面的href未知,cms会为其提供一个id。 虽然a class=“sidr class”下拉开关 我想用CSS隐藏sidr类下拉菜单的内容,只显示一个类“sidr类下拉开关”,这样它就可以点击第一个链接。
我一直在跟一门课,但似乎没有奏效(也可能是我太糟糕了,搞错了什么东西)。 我应该在contenidoactivity.java中输入一个名称,然后按下一个按钮(onclick:enviarNombre被选中),并将该名称获取到destinoactivity.java txt,但它只是停留在那里,当我单击该按钮时,它没有改变任何东西。我已经放了一个吐司“has seleccionado enviar
这是春虫吗?由于logout-success-url已设置且不安全,因此在到达logout-success-url后,似乎不应将用户重定向到无效的会话url。 日志如下所示:
我正在创建一个应用程序,它会在打开任何其他应用程序之前询问密码。为了开始我的活动,我创建了一个intent.SETFLAGS(intent.FLAG_ACTIVITY_NEW_TASK)的标志; 锁定/解锁功能正常工作,但当我按下后退按钮时,它没有重定向到主屏幕。
完成注销后,Azure注销页面不会重定向用户。它只返回以下信息: 你注销了你的账户。关闭所有浏览器窗口是个好主意。 我尝试了不同的注销URL,我发现: > https://login.microsoftonline.com/MY_TENANT/oauth2/logout?post_logout_redirect_uri=https://micway.com.au/ https://login.mi