Tuesday, 17 June 2014

How to manage Login Session in Android Application

Its very difficult to maintain Login Session in android till the time you read this blog. Once you have gone through this blog all doubts will be cleared.


We can Use Shared preferences For Login session, Once the user logs in to your application, you can check its authenticity and once the user logged in to application you can store state of Login for that user.
Steps for User Login Session:
1. Store Login status as true in SharedPreference for authenticate user.
2. Check On Splash(First) Activity for Login Status and depending on that load next Activity
3. On Logout button set Login status False
Here is an sample code snippet for above operation,
Code Snippet SplashActivity
SplashActivity class

String KEY_LOGIN_NAME = "LoginStatus";
SharedPreferences preferences;
------------------------------------------------------------------------
//Initialise sharedPreferences Object
preferences = getSharedPreferences("PREF_NAME", MODE_PRIVATE);
Intent intent ;
------------------------------------------------------------------------
// Check for login status Using SharedPreference
if (!isLogin()) {
  Log.d("Splash Activity ", "User not logged in so Login Screen will appear");
  Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
}
else {
   Log.d("Splash Activity ", "User is logged in so Home Screen will appear");
  intent = new Intent(SplashActivity.this, HomeScreen.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
}
------------------------------------------------------------------------
// Method to check Login Status
private boolean isLogin() {
  return preferences.getBoolean(KEY_LOGIN_NAME, false);
}
code snippet LoginActivity
LoginActivity.class
SharedPreferences preferences;
SharedPreferences.Editor editor;
String KEY_LOGIN_NAME = "LoginStatus";
---------------------------------------------------------------------------
preferences = getSharedPreferences("PREF_NAME", MODE_PRIVATE);
editor = preferences.edit();
btnLoginUser.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
  // Check for valid Username and Password
  if(valid)
  {
   // Valid user
   editor.putBoolean(KEY_LOGIN_NAME, true);
   editor.commit();
  }
  else
  {
   // Enter valid Username or Password
  }
}
});
Code Snippet

For Logout Operation :
btnLoginUser.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Clear from SharedPreference
editor.putBoolean(KEY_LOGIN_NAME,false);
editor.commit();
finish();
}
});


Thanks,
Hopefully this post will Help You…
Happy Coding 


Visit Us- Stark Digital Media Services Pvt Ltd,
Shinde Complex, Near Maratha Mandir, Shinde Nagar, Bavdhan,Pune, Maharashtra 411021.
 020 – 22952445
Our Best Services- Android App development, iOS App Development, Web Development & Design Services etc,

Sunday, 15 June 2014

Apps Monetization



What is app monetization?
Mobile applications stores, be it Apple’s App Store or Google Play, allow the publisher to sell their apps.

Monetizing Your App
Apart from offering paid apps, there are a number of other ways to monetize your mobile app

1) Monetize Premium Apps
2) Monetize Freemium Apps
3) Monetize with Subscriptions
4) E-commerce
5) Monetize with Ads
6) Convenient, Frictionless Purchasing

The above all are monetize model.

1) Monetize Premium Apps – It is also known as paid apps.
Charging users to download your apps is a simple, convenient monetization model.This model could work well for any app or game, but might be particularly relevant to those with extensive features or that address a narrow niche in the market. Certain categories of apps, such as games for children, should be monetized by paying for them up front instead of advertising or in-app purchases.

2) Monetize Freemium Apps
Users are more likely to download free apps and games compared to priced ones. However, we provide you with a number of ways to monetize free apps, using in App Billing With this tool you can sell digital goods that are:

Durable — once purchased the item will always be available to the user, such as additional app features.

Consumable — items that might be used progressively or expire after a period of time, such as a game booster or news subscription.

A basic approach is to offer a free download with limited features or full features for a limited time. Then use an in-app purchase to unlock the full, unlimited app.

3) Monetize with Subscriptions
Subscriptions provide an excellent opportunity to create continuing revenue streams. Subscriptions are similar to digital goods offered through In-app Billing but made available on a recurring monthly or annual basis.