Android 无法启动飞溅活动
我有一个应用程序,我想在应用程序中的某个点重新点击splash活动。通常启动新活动是一项非常简单的任务,但由于某种原因,我无法重新启动我的Android 无法启动飞溅活动,android,android-intent,Android,Android Intent,我有一个应用程序,我想在应用程序中的某个点重新点击splash活动。通常启动新活动是一项非常简单的任务,但由于某种原因,我无法重新启动我的SplashActivity。以下是我到目前为止得到的信息: 清单 <activity android:name=".controller.welcome.SplashScreenActivity" android:screenOrientation="portrait" andr
SplashActivity
。以下是我到目前为止得到的信息:
清单
<activity
android:name=".controller.welcome.SplashScreenActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
但这没有帮助
我正试图从片段中的onCreateView
启动活动:
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if(myStuff == null || mViewModel == null){
Log.d(TAG, "Restarting application....");
try{
Intent intent = new Intent(getContext(), SplashScreenActivity.class);
startActivity(intent);
} catch (Exception e){
Log.d(TAG, "Problem starting activity: " + e.toString());
e.printStackTrace();
}
}
...
我还尝试使用getActivity
和getApplicationContext
创建Intent
。我肯定我遗漏了一些小东西,比如意向过滤器,但我似乎找不到它。任何帮助都将不胜感激 您可以尝试以下方法:
Intent intent = new Intent(this, SplashScreenActivity.class);
我认为“getContext()”与“this”不同 您是否在尝试启动
SplashScreenActivity
时遇到异常?您可能希望您的SplashScreen活动也是默认活动。我遇到了相反的问题,我通过将我的主要活动设置为默认活动来解决它。您使用的是哪个版本的androidtrying@DimaKozhevin,不,我没有例外。Clifford,我正在为当前手机使用7.x。调用方法SplashScreenActivity.onResume()
?
Intent intent = new Intent(this, SplashScreenActivity.class);