How to implement a registration activity in android that works only for once?

I'm designing an application that has an activity for registration process, this activity launches on default. I want this activity to be disabled forever once the registration process has been completed successfully and then it should be replaced by a different activity as the default activity for the rest of the lifetime of the application.I've tried to search my way through this problem but I've hardly found anything.Any help will be much appreciated. Thanks in advance.

-------------Problems Reply------------

Once registration is complete, commit some value to the SharedPreferences, then in your splash screen or some other opening Activity, check the preferences. If the value indicates that the registration is complete, start a different Activity instead of the Registration one...

Example:

public class SplashScreen extends Activity {

public void onCreate(Bundle state) {
super.onCreate(state);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean regComplete = prefs.getBoolean("registration", false);
if(regComplete) {
startActivity(new Intent(this, SomeActivity.class));
} else {
startActivity(new Intent(this, Registration.class));

}
}

Better still:

Always launch the registration, but in onCreate(), simply launch a different Activity immediately and finish() the registration Activity if the prefs indicate that registration is complete.

Edit SharedPreferences explained:

SharedPreferences lets you persist primitive values in your app. You grab the SharedPreferences by doing:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

then you write to SharedPreferences by getting the Editor. To do this, you call

SharedPreferences.Editor editor = prefs.Edit();

then you can commit values to the editor by using key/values:

editor.putBoolean("some string as a key here", true/false);

Then to actually save that, you call editor.commit();

Then you grab values back from SharedPreferences by simply calling

prefs.getBoolean("some previously chosen string as a key here", true/false);

where true/false is the default value that will be returned if no such key exists...

This is convenient and lets you do simple things like:

editor.putInt("some important number", 55);
editor.commit();

......later

int i = prefs.getInt("some important number", -1);

if(i != -1) {
//do stuff
} else {
//do other stuff
}

Also, please see: http://developer.android.com/guide/topics/data/data-storage.html#pref

Don't have the registration Activity be the default. Instead have another Activity as the default, and then at runtime it can check to see which Activity it should send the user to. If they haven't registered then startIntent( RegistrationActivity.class ).

Category:android Views:1 Time:2012-01-26

Related post

  • What's the best way to implement a Registration REST API for iPhone/Android? 2011-02-05

    I'm writing a backend application with REST API for iPhone and Android. It's an internal API. At this point, I'm trying to implement a user registration API such that the user can register from the mobile app. I'm writing using Django and with Django

  • implement a spinning activity indicator similar to iOS in Android 2011-08-29

    I am trying to implement the spinning activity similar to the the one I have placed below in Android. I believe I should use the ProgressDialog. My issue arises from how to actually manipulate the ProgressDialog to appear like the activity indicator.

  • Implementing In App purchases in Android? 2010-01-07

    Edit: Android now supports in-app billing! Original question: It looks like Android won't natively support in-app purchases for a while, and when it does there might be a huge user base with devices that don't support them. What's the best way to imp

  • Fullscreen Activity in Android? 2010-05-19

    How do I make an activity full screen? I mean without the notification bar. Any ideas? --------------Solutions------------- You can do it programatically: public class ActivityName extends Activity { @Override public void onCreate(Bundle savedInstanc

  • Reload activity in Android 2010-06-16

    Is it a good practice to reload an activity in Android? What would be the best way to do it? this.finish and then this.startActivity with the activity intent? --------------Solutions------------- You can Simply use finish(); startActivity(getIntent()

  • What is the class that implement the CallLog ListView in android source code? 2011-01-04

    Hey I want to know what is the class that implement the ListView in CallLog. I mean I have all this package http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=tree But I dont know what class in this package implements the CallLog

  • Black screen when returning to video playback activity in Android 2011-06-14

    I'm currently developing the android application ServeStream and I've encountered and problem that I can't fix. My application will stream music and video using the android MediaPlayer class. I've modeled my class after the example found at: http://d

  • Implementing AutoComplete with ListView in Android 2011-10-27

    I was following this example: http://developer.android.com/resources/tutorials/views/hello-autocomplete.html And I want to know how I can implement this with a ListView instead of the dropdown window that is supplied with this TextView. For instance,

  • How to perform two operations on one activity in android 2011-11-21

    I want to implement a search in my Android application. In this page, first I am displaying a user list and then performing a search on the user list. Both are in the same activity. In the following manner, I am getting intent and some values from th

  • Refresh view or activity on android 2011-12-28

    I have 1 activity that receives a json object from the server (database) and every activity called view (TableLayout but in ScrollView) automatically updates. But when I delete the data in the database (from current activity or directly from the data

  • how to implement TimeChart in achartengine with android 2012-01-15

    I'm new in android and I want to use achartengine to implement time chart that represent the daily outgoing call durations from call log. Does any one know how can I do this and what should I do? --------------Solutions------------- So you need a lay

  • Pass Data form listview to another activity in android? 2012-01-31

    I used the below code for displaying all cities time. When i execute my code the time will displayed in a list view, now my problem is once i click any one of the country (position in list), i must pass the Country name, day, month, year and time fro

  • How to implement Drag and Drop in android 2.2? 2012-02-16

    I am trying to develop an android app, where user should be able to drag images from one cell of a grid to another. To implement this I need Drag and Drop API which was introduced in Android 3.0, but my app should run in Android 2.2. So, is there a w

  • How to implement custom Tab Host in Android 2012-03-28

    How to make this kind of tab in Android [http://i.stack.imgur.com/rIbUX.png] just mention that see the overlap area, when you click on of the tab, the overlap changed. here is one chinese version example in which I think that's what I want to have, b

  • What's the best manner of implementing a social activity stream? 2008-10-14

    I'm interested in hearing your opinions in which is the best way of implementing a social activity stream (Facebook is the most famous example). Problems/challenges involved are: Different types of activities (posting, commenting ..) Different types

  • How to create a Bottom-Top animation when close/stop an activity in android 2009-10-10

    How can I create a Slide-Bottom-To-Top animation when close/stop an activity in android application? --------------Solutions------------- For the animation, use something like hideWithSlideUp = new TranslateAnimation(0, 0, 0, -displayHeight); You may

  • How to create Transparent Activity in Android? 2010-02-01

    I want to create a transparent Activity on top of another activity. How can I achieve this? --------------Solutions------------- Add the following style In your res/values/styles.xml file (if you don’t have one, create it.) Here’s a complete file:

  • How to provide animation when calling another activity in Android? 2010-04-16

    I have two Activities A and B. I want to have the shrink Animation when Activity A calls B and maximize animation when Activity B calls A. I don't need the animation xml files for this. When we call another Activity in Android it gives its default an

  • How to implement push notification for multiple Android apps? 2010-07-02

    Our products still target OS 1.5+, so C2DM in Froyo is not an option. I think wrap a persistent TCP connection in a service would be feasible. But I'm still wondering how to use one service to receive notifications for multiple applications. I don't

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.087 (s). 11 q(s)