Changing Activities

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Changing Activities

Postby Skeniver » Fri Sep 18, 2009 11:46 am

Hi there

I am trying to create a 'pin pad' style log in activity that will require users to enter a pin before being able to access the app.

The 'home' activity of the app will run and check if there are any users. If there aren't, it will ask them to set one up (by displaying an AlertDialog) and then running the 'add user activity', which is shown as a dialog itself. This runs fine.

If the 'home' activity does find a user, then it will run my pin pad activity, as a dialog too. The problem is that it isn't showing the pin pad activity, because it seems it hasn't finished running the home activity. If I put a meaningless dialog before running the Pin pad, it runs fine! But I don't want a useless dialog to show up before the user gets to the pin screen.

Here is some code:


The main 'home' activity runs this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     public void onCreate(Bundle savedInstanceState) {
  3.  
  4.         super.onCreate(savedInstanceState);
  5.  
  6.        
  7.  
  8.         setContentView(R.layout.home);
  9.  
  10.        
  11.  
  12.         dba.open();
  13.  
  14.         if (dba.getUserCount() <= 0) {
  15.  
  16.                 noUsers = true;
  17.  
  18.                 makeDialog(Global.DIALOG_NOUSERS, "Welcome", "You need to create an account");
  19.  
  20.             } else {
  21.  
  22.                 runPinPad();
  23.  
  24.             }
  25.  
  26. }
  27.  
  28.  
  29.  
  30.     private void runPinPad() {
  31.  
  32.                         dba.close();
  33.  
  34.                         Intent i = new Intent(cont, Pinpad.class);
  35.  
  36.                         startActivityForResult(i, Global.ACTIVITY_PINPAD);
  37.  
  38.     }
  39.  
  40.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


makeDialog, displays a standard AlertDialog before taking the user to a new user activity. RunPinPad just runs the new activity...

However, if i show a useless alert dialog first, it runs fine...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     private void runPinPad() {
  3.  
  4.         AlertDialog.Builder ad = new AlertDialog.Builder(cont);
  5.  
  6.         ad.setMessage("Please login");
  7.  
  8.         ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  9.  
  10.                         @Override
  11.  
  12.                         public void onClick(DialogInterface dialog, int which) {
  13.  
  14.                         dba.close();
  15.  
  16.                         Intent i = new Intent(cont, Pinpad.class);
  17.  
  18.                         startActivityForResult(i, Global.ACTIVITY_PINPAD);
  19.  
  20.                         }
  21.  
  22.                 });
  23.  
  24.         ad.show();
  25.  
  26.     }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Please help someone...
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests