I am creating an app that is a ticket sales system. On the checkout page (the PaymentScreen activity) a check is performed to ensure that the customer is signed into their account, and if they are not, they are redirected to log in before continuing to checkout.
When I check to see if a customer is signed in, the code correctly verifies that the customer is not signed in, and then executes that if function (I can tell from LogCat), but the activity is never launched and the code continues to execute.
Any help would be appreciated – I can’t seem to figure this one out.
PaymentScreen.java:
public class PaymentScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.paymentscreen);
if(Singleton.getInstance().selected_city == null) {
PaymentScreen.this.startActivity(new Intent().setClass(PaymentScreen.this, CityList.class));
}
if(Singleton.getInstance().selected_venue == null) {
PaymentScreen.this.startActivity(new Intent().setClass(PaymentScreen.this, VenueList.class));
}
if(Singleton.getInstance().selected_event == null) {
PaymentScreen.this.startActivity(new Intent().setClass(PaymentScreen.this, EventList.class));
}
if(Singleton.getInstance().customer == null) {
PaymentScreen.this.startActivity(new Intent().setClass(PaymentScreen.this, LoginScreen.class).putExtra("sendToActivity", "PaymentScreen"));
Log.d("LineBouncer", "in if statement and (customer == null) is true");
}
if(Singleton.getInstance().customer == null) {
Log.d("LineBouncer", "customer is null");
}
new GetPrepurchaseId().execute();
}
}
LogCat:
06-19 02:10:22.972: D/LineBouncer(3102): in if statement and (customer == null) is true
06-19 02:10:22.972: D/LineBouncer(3102): customer is null
AndroidManifest.xml:
<activity android:name=".CityList" android:label="@string/app_name"></activity>
<activity android:name=".LoginScreen" android:label="@string/app_name"></activity>
<activity android:name=".CreateAccount" android:label="@string/app_name"></activity>
<activity android:name=".VenueList" android:label="@string/app_name"></activity>
<activity android:name=".EventList" android:label="@string/app_name"></activity>
<activity android:name=".EventDetails" android:label="@string/app_name"></activity>
<activity android:name=".PaymentScreen" android:label="@string/app_name"></activity>
<activity android:name=".OrderHistory" android:label="@string/app_name"></activity>
<activity android:name=".PassView" android:label="@string/app_name"></activity>
So clearly from the LogCat the program recognizes that the customer is null and runs over the StartActivity code, but then continues to run and never actually starts that activity.
Thanks!
The right way to start activity is as follows: