2016-08-17 50 views
1

我使用電報源和我有改變發射活動與此代碼在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> 

我該如何解決這個問題?

+0

請將崩潰堆棧跟蹤粘貼; ) – Klawikowski

+0

它不依賴於崩潰,在任何崩潰後,一次,發射器活動更改爲「org.telegram.ui.LaunchActivity」(抱歉我的英語不好)@Klawikowski – Omid

+0

請檢查我的答案:) – Klawikowski

回答

1

好吧,據我所知,你想在崩潰發生後開始指定的活動。

第一步 實現自己的異常處理程序,然後將其設置的onCreate中應用類或活動(我不知道你的應用程序拱的樣子):

Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); 

第二步 做異常處理程序內部的魔力。例如:

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); 


} 

}

它是如何工作的?每次你會發生崩潰,你的處理程序會抓住它,並完成這項工作。我希望那就是你想要的。

+0

no i我不是在尋找這個,我正在使用電報來源(在github上可用),我改變了項目啓動器的活動,但是當應用程序崩潰時,我打開應用程序,我看到另一個活動(崩潰後不顯示我的啓動器活動) ,我使用你的代碼來改變那個活動,但沒有奏效 – Omid