if there is no status intent yet, then create one, and don't NPE

This commit is contained in:
Nathan Freitas 2016-11-16 07:50:40 -05:00
parent 84d6a767ae
commit 45105572d9
1 changed files with 6 additions and 2 deletions

View File

@ -103,7 +103,7 @@ public class OrbotMainActivity extends AppCompatActivity
private ActionBarDrawerToggle mDrawerToggle; private ActionBarDrawerToggle mDrawerToggle;
/* Some tracking bits */ /* Some tracking bits */
private String torStatus = null; //latest status reported from the tor service private String torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
private Intent lastStatusIntent; // the last ACTION_STATUS Intent received private Intent lastStatusIntent; // the last ACTION_STATUS Intent received
private SharedPreferences mPrefs = null; private SharedPreferences mPrefs = null;
@ -1194,6 +1194,10 @@ public class OrbotMainActivity extends AppCompatActivity
{ {
autoStartFromIntent = false; autoStartFromIntent = false;
Intent resultIntent = lastStatusIntent; Intent resultIntent = lastStatusIntent;
if (resultIntent == null)
resultIntent = new Intent(TorServiceConstants.ACTION_START);
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus); resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
setResult(RESULT_OK, resultIntent); setResult(RESULT_OK, resultIntent);
finish(); finish();