fixex problem with multiple versions of MainActvity being started by StartUpActivity

This commit is contained in:
Graham Jones
2016-03-30 20:56:39 +01:00
parent 8944cbc6d3
commit dc311ae079
3 changed files with 23 additions and 13 deletions

View File

@@ -311,7 +311,9 @@ public class SdServer extends Service implements SdDataReceiver {
}
Intent i = new Intent(getApplicationContext(), MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent contentIntent =
PendingIntent.getActivity(this,
0, i, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
Notification notification = builder.setContentIntent(contentIntent)
.setSmallIcon(iconId)

View File

@@ -60,6 +60,7 @@ public class StartupActivity extends Activity {
private OsdUtil mUtil;
private Timer mUiTimer;
private SdServiceConnection mConnection;
private boolean mStartedMainActivity = false;
final Handler mServerStatusHandler = new Handler(); // used to update ui from mUiTimer
@@ -282,18 +283,23 @@ public class StartupActivity extends Activity {
// If all the parameters are ok, close this activity and open the main
// user interface activity instead.
if (allOk) {
Log.v(TAG, "starting main activity...");
try {
Intent intent = new Intent(
getApplicationContext(),
MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
finish();
} catch (Exception ex) {
Log.v(TAG, "exception starting settings activity " + ex.toString());
if (!mStartedMainActivity) {
Log.v(TAG, "starting main activity...");
try {
Intent intent = new Intent(
getApplicationContext(),
MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
mStartedMainActivity = true;
finish();
} catch (Exception ex) {
mStartedMainActivity = false;
Log.v(TAG, "exception starting main activity " + ex.toString());
}
} else {
Log.v(TAG,"allOk, but already started MainActivity so not doing anything");
}
}
}
};