这给了我一个艰难的时间,无论我按什么按回按钮都会将应用程序返回到登录活动。
这些方法是我迄今为止尝试过的方法:
1:我尝试设置意图标记以清除顶部,删除历史记录并将活动排除在最近。
Intent intent = new Intent(MainActivity.this, NoticeAndStuff.class);
intent.addFlags(intent.FLAG_ACTIVITY_NO_HISTORY | intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
2:我也尝试在startActivity()调用后使用finish()。
Intent intent = new Intent(MainActivity.this, NoticeAndStuff.class);
startActivity(intent);
finish();
毋庸置疑,我也同时尝试了它们,并且还尝试在清单文件中设置noHistory标志以确保。我也尝试覆盖后退按钮,但后退按钮返回到登录活动。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".app.AppController"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".SplashScreen"
android:label="@string/app_name"
android:noHistory="true"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:noHistory="true"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity
android:name=".NoticeAndStuff"
android:label="@string/title_activity_notice_and_stuff"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity
android:name=".Subscriptions"
android:label="@string/title_activity_subscriptions"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity
android:name=".Details"
android:label="@string/title_activity_details"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity
android:name=".Abouts"
android:label="@string/title_activity_abouts"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
<activity
android:name=".FeedBack"
android:label="@string/title_activity_feed_back"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
</application>
答案 0 :(得分:2)
在最糟糕的情况下尝试
var storage = window.localStorage;
var id = storage.getItem('id');
这将在没有任何痕迹的情况下销毁当前活动,如果这样做,则不会将意图传递给其他活动。
快乐编码。
答案 1 :(得分:1)
试试这个。
Intent intent =new Intent(CurrentActivity.this,NextActivity.class);
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
答案 2 :(得分:1)
我假设你的清单应该有像他的
这样的细节 <activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NoticeAndStuff"
android:label="@string/title_activity_name"
android:theme="@style/AppTheme.NoActionBar" />
MainActivity应该是类扩展活动类或AppCompatActivity
导航到下一个屏幕将是
void moveToNextScreen(){
startActivity(new Intent(getApplicationContext(), NoticeAndStuff.class));
this.finish();
}
然后确保每次更改代码时都清理并重建构建文件。在Android工作室中,它将是&#34; Drive Path \ AppName \ app \ build&#34;您可以手动删除并再次尝试清理构建。除此之外可能没有任何错误。
编辑:如果所有这些都无法正常工作,请将其放在您的后门按钮上
finishAffinity();
检查这个deails:API Details
完成此活动以及紧接其下的所有活动 具有相同亲和力的当前任务。这通常是使用的 当应用程序可以启动到另一个任务(例如来自 它理解的内容类型的ACTION_VIEW,并且用户已经使用过 向上导航切换出当前任务并进入自己的任务 任务。在这种情况下,如果用户已导航到任何其他用户 第二个应用程序的活动,所有这些应该被删除 从原始任务作为任务切换的一部分。
请注意,此完成功能不允许您将结果传递给 以前的活动,如果你正在尝试,将抛出异常 这样做。
答案 3 :(得分:1)
Try this
Intent ii2 = new Intent(getApplicationContext(), FacebookSharing.class);
ii2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(ii2);
finish();
答案 4 :(得分:1)
我认为一切都很好,只要尝试一下你已经完成的事情。
Intent intent = new Intent(MainActivity.this, NoticeAndStuff.class);
startActivity(intent);
finish();
但我认为您需要从设备中卸载该应用。然后在设备上再次构建和运行之前清理并重建项目。然后运行该应用程序,然后让我们知道它是否是相同的结果。
答案 5 :(得分:1)
这有点棘手,试试这个。
使用 FLAG_ACTIVITY_NEW_TASK 和 FLAG_ACTIVITY_CLEAR_TASK 将执行 特技
Collection
快乐编码.. !!
答案 6 :(得分:0)
尝试在android:noHistory="true"
manifest.xml
如果不起作用,请尝试
Intent i=new Intent(MainActivity.this, NoticeAndStuff.class);
i.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(i);