Android Open Source - muwifi-autologin Shortcut Activity






From Project

Back to project page muwifi-autologin.

License

The source code is released under:

Copyright 2011-2014 Pawit Pornkitprasan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are...

If you think the Android project muwifi-autologin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dyndns.pawitp.muwifiautologin;
/* www. j  ava2s.co  m*/
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

public class ShortcutActivity extends Activity {

    public static final String SHORTCUT_INTENT = "org.dyndns.pawitp.muwifiautologin.SHORTCUT";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        boolean isLogout = getIntent().getBooleanExtra(MuWifiLogin.EXTRA_LOGOUT, false);
        Utils.checkWifiAndDoLogin(this, isLogout);

        finish();
    }

    public static class CreateLoginShortcut extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setResult(RESULT_OK, createShortcutIntent(this, false));
            finish();
        }

    }

    public static class CreateLogoutShortcut extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setResult(RESULT_OK, createShortcutIntent(this, true));
            finish();
        }

    }

    private static Intent createShortcutIntent(Context context, boolean isLogout) {
        Intent shortcutIntent = new Intent(ShortcutActivity.SHORTCUT_INTENT);
        shortcutIntent.putExtra(MuWifiLogin.EXTRA_LOGOUT, isLogout);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            addClearTaskFlag(shortcutIntent);
        } else {
            // This will cause the Setting page to disappear from recents
            shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
        }
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Intent.ShortcutIconResource iconResource = Intent.ShortcutIconResource.fromContext(context, R.drawable.icon);

        Intent intent = new Intent();
        intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getString(isLogout ? R.string.logout : R.string.login));
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
        return intent;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private static void addClearTaskFlag(Intent intent) {
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    }

}




Java Source Code List

org.dyndns.pawitp.muwifiautologin.ArubaClient.java
org.dyndns.pawitp.muwifiautologin.CiscoClient.java
org.dyndns.pawitp.muwifiautologin.IcClient.java
org.dyndns.pawitp.muwifiautologin.LoginClient.java
org.dyndns.pawitp.muwifiautologin.LoginException.java
org.dyndns.pawitp.muwifiautologin.MuWifiLogin.java
org.dyndns.pawitp.muwifiautologin.MySSLSocketFactory.java
org.dyndns.pawitp.muwifiautologin.NetworkStateChanged.java
org.dyndns.pawitp.muwifiautologin.PostRetryHandler.java
org.dyndns.pawitp.muwifiautologin.Preferences.java
org.dyndns.pawitp.muwifiautologin.ShortcutActivity.java
org.dyndns.pawitp.muwifiautologin.Utils.java