Java 在电报源崩溃后更改启动器活动

Java 在电报源崩溃后更改启动器活动,java,android,android-manifest,telegram,Java,Android,Android Manifest,Telegram,我使用的是电报源,我已经用AndroidManifest.xml中的代码更改了启动器活动 <activity android:name="org.telegram.memberbegir.ActivitySplash" android:screenOrientation="portrait" android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">

我使用的是电报源,我已经用AndroidManifest.xml中的代码更改了启动器活动

<activity
        android:name="org.telegram.memberbegir.ActivitySplash"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
        </intent-filter>
    </activity>

但当应用程序发生崩溃时,启动器活动会更改为以这种方式定义的另一个活动

<activity
        android:name="org.telegram.ui.LaunchActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:hardwareAccelerated="@bool/useHardwareAcceleration"
        android:windowSoftInputMode="adjustPan"></activity>


如何解决此问题?

据我所知,您希望在崩溃发生后启动指定的活动

第一步 实现您自己的异常处理程序,然后在应用程序类或活动中将其设置为onCreate(我不知道您的应用程序arch是什么样子):

第二步 在异常处理程序内部执行此操作。例如:

public class ExceptionHandler implements
    java.lang.Thread.UncaughtExceptionHandler {
private final Context myContext;

public ExceptionHandler(Context context) {
    myContext = context;
}

public void uncaughtException(Thread thread, Throwable exception) {
    ...
    Intent intent = new Intent(myContext, AnotherActivity.class);
    //you can add intent flags like Intent.FLAG_ACTIVITY_CLEAR_TOP to clear the activity stack etc
    myContext.startActivity(intent);


}
}


它是如何工作的?每次发生崩溃时,您的处理程序都会捕捉到它,并完成任务。我希望这就是您想要的。

请粘贴崩溃堆栈跟踪;)这不取决于崩溃,在任何崩溃之后,有一次,启动器活动更改为“org.telegram.ui.LaunchActivity”(抱歉我的英语不好)@klawikowski请检查我的答案:)不,我不是在寻找这个,我使用的是电报源(可在github上获得),我更改了项目启动器活动,但当应用程序崩溃时,当我打开应用程序时,我看到另一个活动(崩溃后不要显示我的启动程序活动),我使用你的代码来更改该活动,但不起作用
public class ExceptionHandler implements
    java.lang.Thread.UncaughtExceptionHandler {
private final Context myContext;

public ExceptionHandler(Context context) {
    myContext = context;
}

public void uncaughtException(Thread thread, Throwable exception) {
    ...
    Intent intent = new Intent(myContext, AnotherActivity.class);
    //you can add intent flags like Intent.FLAG_ACTIVITY_CLEAR_TOP to clear the activity stack etc
    myContext.startActivity(intent);


}