Example usage for android.content Intent getAction

List of usage examples for android.content Intent getAction

Introduction

In this page you can find the example usage for android.content Intent getAction.

Prototype

public @Nullable String getAction() 

Source Link

Document

Retrieve the general action to be performed, such as #ACTION_VIEW .

Usage

From source file:com.easemob.chatuidemo.ui.MainActivity.java

private void registerBroadcastReceiver() {
    broadcastManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED);
    intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED);
    broadcastReceiver = new BroadcastReceiver() {

        @Override//from  w  w w  .  ja v  a2 s .c  o m
        public void onReceive(Context context, Intent intent) {
            updateUnreadLabel();
            updateUnreadAddressLable();
            if (currentTabIndex == 0) {
                // ??????
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            } else if (currentTabIndex == 1) {
                if (contactListFragment != null) {
                    contactListFragment.refresh();
                }
            }
            String action = intent.getAction();
            if (action.equals(Constant.ACTION_GROUP_CHANAGED)) {
                if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
                    GroupsActivity.instance.onResume();
                }
            }
        }
    };
    broadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}

From source file:nf.frex.android.FrexActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
        return;//  w  w w.  j  a va 2  s .com
    }
    if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) {
        final Uri imageUri = data.getData();
        if (imageUri != null) {
            File imageFile = new File(imageUri.getPath());
            String configName = FrexIO.getFilenameWithoutExt(imageFile);
            File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT);
            try {
                FileInputStream fis = new FileInputStream(paramFile);
                try {
                    readFrexDoc(fis, configName);
                } finally {
                    fis.close();
                }
            } catch (IOException e) {
                Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()),
                        Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == R.id.settings) {
        view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this));
    } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) {
        final Uri imageUri = data.getData();
        final ColorQuantizer colorQuantizer = new ColorQuantizer();
        final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this);
        final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                colorQuantizer.cancel();
            }
        };
        final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() {
            @Override
            public void progress(final String msg, final int iter, final int maxIter) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        progressDialog.setMessage(msg);
                        progressDialog.setProgress(iter);
                    }
                });
            }
        };

        progressDialog.setTitle(getString(R.string.get_pal_from_img_title));
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setCancelable(true);
        progressDialog.setOnCancelListener(cancelListener);
        progressDialog.setMax(colorQuantizer.getMaxIterCount());
        progressDialog.show();

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                Bitmap bitmap;
                try {
                    bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256);
                } catch (IOException e) {
                    alert("I/O error: " + e.getLocalizedMessage());
                    return;
                }
                ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener);
                progressDialog.dismiss();
                if (colorScheme != null) {
                    Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme");
                    String colorSchemeId = "$" + imageUri.toString();
                    colorSchemes.add(colorSchemeId, colorScheme);
                    view.setColorSchemeId(colorSchemeId);
                    view.setColorScheme(colorScheme);
                    view.recomputeColors();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)");
                            showDialog(R.id.colors);
                        }
                    });

                }
            }
        });
        thread.start();
    }
}

From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_MULTI_PROCESS);

    // Creates an indeterminate processing notification until the work is complete
    mNotificationsHelper = new NotificationsHelper(this)
            .createNotification(com.dycody.android.idealnote.R.drawable.ic_content_save_white_24dp,
                    getString(com.dycody.android.idealnote.R.string.working), null)
            .setIndeterminate().setOngoing().show();

    // If an alarm has been fired a notification must be generated
    if (ACTION_DATA_EXPORT.equals(intent.getAction())) {
        exportData(intent);//w  w  w . j a va 2s.co m
    } else if (ACTION_DATA_IMPORT.equals(intent.getAction())) {
        importData(intent);
    } else if (ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) {
        importDataFromSpringpad(intent);
    } else if (ACTION_DATA_DELETE.equals(intent.getAction())) {
        deleteData(intent);
    }
}

From source file:com.moonpi.tapunlock.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();

    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

        // Get tag ID and turn into String
        byte[] tagIDbytes = tag.getId();
        tagID = bytesToHex(tagIDbytes);//w  ww. j  a  v  a2  s .  com

        if (!tagID.equals("")) {
            // Dismiss the 'Scan NFC Tag' dialog and show the 'Set tag name' dialog
            dismissDialog(DIALOG_READ);

            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

            MainActivity.this.showDialog(DIALOG_SET_TAGNAME);
        }
    }
}

From source file:edu.cmu.mpcs.dashboard.TagViewer.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);// ww  w.  j a  va 2s. c  o  m
    Log.d("TAG_VIEWER", "on new intent actually fired ");
    if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {

        resolveIntent(intent);
    }

    // Tag writing mode
    if (writeContent != null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Log.d("TAG_VIEWER", "in Oncreate Before writing");

        // new AlertDialog.Builder(TagViewer.this)
        // .setTitle("Touch tag to write")
        // .setOnCancelListener(
        // new DialogInterface.OnCancelListener() {
        // public void onCancel(DialogInterface dialog) {
        // disableTagWriteMode();
        //
        // }
        // }).create().show();

        Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        try {
            WriteToTag.write(detectedTag, writeContent);
            Context context = getApplicationContext();
            CharSequence text = "Tag sucessfully written!!";
            int duration = Toast.LENGTH_LONG;
            Toast toast = Toast.makeText(context, text, duration);
            toast.show();

            Log.d("TAG_VIEWER", "Before calling dialog.cancel");
            dialog.dismiss();
            finish();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Log.d("TAG_VIEWER", "in on create, writing to tag");
    }
    //
    // // Tag writing mode
    // if (mWriteMode
    // &&
    // NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()))
    // {
    // Tag detectedTag =
    // intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    // try {
    // WriteToTag.write(detectedTag);
    // } catch (IOException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // } catch (FormatException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    // Log.d("TAG_VIEWER", "in on new intent, writing to tag");
    // }
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

/** Called when the activity is first created. */
@Override/*w  w w.j  ava 2s. c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    resetContent();

    final Intent i = this.getIntent();
    // Decide if application is called from launcher or from other application
    // by using action. If you use category it can be null, that is the case
    // with gmail application and link from that application.
    if (Intent.ACTION_VIEW.equals(i.getAction())) {
        // Link to comic
        boolean tryArchive = true;
        if (comicDef.isComicUrl(i.getData())) {
            try {
                loadComic(provider.comicDataUrlForUrl(i.getData()));
                tryArchive = false;
            } catch (NumberFormatException e) {
                // Fall through to trying the URL as an archive URL
            }
        }
        if (tryArchive) {
            if (comicDef.isArchiveUrl(i.getData())) {
                showArchive();
                this.finish();
            } else {
                // it wasn't a link to comic or to the archive
                // last ditch attempt: was it a link to the home page?
                if (comicDef.isHomeUrl(i.getData())) {
                    goToFinal();
                } else {
                    toast("This comic viewer can't display this content.");
                    this.finish();
                }
            }
        }
    } else {
        // Started by application icon
        if (isReopenLastComic()) {
            try {
                loadComic(createComicUri(getLastReadComic()));
            } catch (NumberFormatException e) {
                goToFinal();
            }
        } else {
            goToFinal();
        }
    }
}

From source file:edu.mit.media.funf.probe.Probe.java

protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, getDisplayName() + ": " + action);
    Log.d(TAG, "Component: " + intent.getComponent() == null ? "<none>" : intent.getComponent().getClassName());

    getHistoryPrefs();//from w  w w . j  a  va 2  s .  c o m
    if (requestsIntent == null) {
        loadRequestsIntent(intent);
        if (requestsIntent == null) {
            Log.d(TAG, "Did not successfully load requests Intent");
            return;
        }
    }

    updateRequests();

    Log.d(TAG, "RunIntent " + (requestsIntent == null ? "<null>" : "exists"));

    if (intent.getComponent().getClassName().equals(Probe.class.getName())) { // Internally queued, not available outside of probe class
        if (ACTION_RUN.equals(action) || ACTION_STOP.equals(action) || ACTION_DISABLE.equals(action)) {
            ProbeScheduler scheduler = getScheduler();
            ArrayList<Intent> requests = requestsIntent.getParcelableArrayListExtra(INTERNAL_REQUESTS_KEY);
            Log.d(TAG, "Requests:" + requests);
            if (isAvailableOnDevice() && !ACTION_DISABLE.equals(action)
                    && scheduler.shouldBeEnabled(this, requests)) {
                if (ACTION_RUN.equals(action)) {
                    _run();
                } else {
                    _stop();
                }
            } else {
                _disable();
                updateInternalRequestsPendingIntent();
            }

            Long nextScheduledTime = scheduler.scheduleNextRun(this, requests);
            Log.d(TAG, "Next scheduled time: " + nextScheduledTime);
            if (nextScheduledTime == null) {
                getHistoryPrefs().edit().remove(NEXT_RUN_TIME_KEY).commit();
            } else {
                getHistoryPrefs().edit().putLong(NEXT_RUN_TIME_KEY, nextScheduledTime).commit();
            }
        } else if (ACTION_INTERNAL_CALLBACK_REGISTERED.equals(action)) {
            Intent callbackRegisteredIntent = intent.getParcelableExtra(INTERNAL_CALLBACK_INTENT);
            PendingIntent callback = intent.getParcelableExtra(CALLBACK_KEY);
            _callback_registered(callbackRegisteredIntent, callback);
        }
    } else if (ACTION_REQUEST.equals(action) || action == null) {
        ArrayList<Bundle> test = Utils.getArrayList(intent.getExtras(), REQUESTS_KEY);
        Log.d(TAG, "REQUEST: " + test);
        boolean succesfullyQueued = queueRequest(intent);
        if (succesfullyQueued) {
            run();
        }
    } else if (ACTION_INTERNAL_REQUESTS.equals(action)) {

    } else if (ACTION_RUN.equals(action)) { // External stop, queue up stop
        run();
    } else if (ACTION_STOP.equals(action)) { // External stop, queue up stop
        stop();
    } else if (ACTION_DISABLE.equals(action)) { // External disable, queue up disable
        disable();
    } else if (ACTION_SEND_DETAILS.equals(action)) { // DOESN'T NEED requests
        PendingIntent callback = intent.getParcelableExtra(CALLBACK_KEY);
        sendProbeDetails(callback);
    } else if (ACTION_SEND_CONFIGURATION.equals(action)) {
        //PendingIntent callback = intent.getParcelableExtra(CALLBACK_KEY);
        //sendProbeConfiguration(callback);
    } else if (ACTION_SEND_STATUS.equals(action)) { // DOESN'T NEED requests
        PendingIntent callback = intent.getParcelableExtra(CALLBACK_KEY);
        sendProbeStatus(callback);
    } else {
        onHandleCustomIntent(intent);
    }
}

From source file:cn.moon.superwechat.ui.MainActivity.java

private void registerBroadcastReceiver() {
    broadcastManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED);
    intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED);
    intentFilter.addAction(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION);
    broadcastReceiver = new BroadcastReceiver() {

        @Override/* w  w  w .  j a  va 2  s.com*/
        public void onReceive(Context context, Intent intent) {
            updateUnreadLabel();
            updateUnreadAddressLable();
            if (currentTabIndex == 0) {
                // refresh conversation list
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            } else if (currentTabIndex == 1) {
                if (contactListFragment != null) {
                    contactListFragment.refresh();
                }
            }
            String action = intent.getAction();
            if (action.equals(Constant.ACTION_GROUP_CHANAGED)) {
                if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
                    GroupsActivity.instance.onResume();
                }
            }
            //red packet code : ???
            if (action.equals(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION)) {
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            }
            //end of red packet code
        }
    };
    broadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}

From source file:fr.bmartel.android.iotf.app.ConnectActivity.java

protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    setContentView(R.layout.activity_connect);

    final Intent intent = getIntent();

    String defaultOrgId = "";
    String defaultApiKey = "";
    String defaultApiToken = "";

    if (BuildConfig.BLUEMIX_IOT_ORG != null)
        defaultOrgId = BuildConfig.BLUEMIX_IOT_ORG;
    if (BuildConfig.BLUEMIX_API_KEY != null)
        defaultApiKey = BuildConfig.BLUEMIX_API_KEY;
    if (BuildConfig.BLUEMIX_API_TOKEN != null)
        defaultApiToken = BuildConfig.BLUEMIX_API_TOKEN;

    String organizationId = sharedpreferences.getString(StorageConst.STORAGE_ORGANIZATION_ID, defaultOrgId);
    String apiKey = sharedpreferences.getString(StorageConst.STORAGE_API_KEY, defaultApiKey);
    String apiToken = sharedpreferences.getString(StorageConst.STORAGE_API_TOKEN, defaultApiToken);
    boolean ssl = sharedpreferences.getBoolean(StorageConst.STORAGE_USE_SSL, true);

    boolean fromJsonFile = false;

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {

        String jsonContent = loadFile(intent);

        try {/* www  .j  av a 2 s .c o m*/
            JSONObject json = new JSONObject(jsonContent);

            if (json.has(StorageConst.STORAGE_API_KEY) && json.has(StorageConst.STORAGE_API_TOKEN)
                    && json.has(StorageConst.STORAGE_ORGANIZATION_ID)
                    && json.has(StorageConst.STORAGE_USE_SSL)) {

                organizationId = json.getString(StorageConst.STORAGE_ORGANIZATION_ID);
                apiKey = json.getString(StorageConst.STORAGE_API_KEY);
                apiToken = json.getString(StorageConst.STORAGE_API_TOKEN);
                ssl = json.getBoolean(StorageConst.STORAGE_USE_SSL);

                SharedPreferences.Editor editor = sharedpreferences.edit();
                editor.putString(StorageConst.STORAGE_ORGANIZATION_ID, organizationId);
                editor.putString(StorageConst.STORAGE_API_KEY, apiKey);
                editor.putString(StorageConst.STORAGE_API_TOKEN, apiToken);
                editor.putBoolean(StorageConst.STORAGE_USE_SSL, ssl);
                editor.commit();

                fromJsonFile = true;

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    ScrollView scrollView = (ScrollView) findViewById(R.id.scrollview);

    mOrganizationEditText = (EditText) scrollView.findViewById(R.id.organization);
    mApikeyEditText = (EditText) scrollView.findViewById(R.id.api_key);
    mApitokenEditText = (EditText) scrollView.findViewById(R.id.api_token);
    mOrganizationEditText.setText(organizationId);
    mApikeyEditText.setText(apiKey);
    mApitokenEditText.setText(apiToken);
    mSslCheckbox = (CheckBox) scrollView.findViewById(R.id.ssl);
    mSslCheckbox.setChecked(ssl);
    mReconnectCheckbox = (CheckBox) scrollView.findViewById(R.id.reconnect);
    mReconnectCheckbox.setChecked(true);

    if (fromJsonFile) {
        connect();
    }

    initNv();
}

From source file:am.roadpolice.roadpolice.alarm.AlarmReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    if (context == null || intent == null) {
        Logger.error("AlarmReceiver", "onReceive(Context " + (context == null ? "null," : ",") + " Intent "
                + (intent == null ? "null)" : ")"));
        return;/*from   w w w . ja  va 2  s.com*/
    }

    // Set Context
    mContext = context;

    // Get shared preferences.
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    // Check internet availability and only in that case start actions.
    final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    final boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

    final String action = intent.getAction();
    // Catch Network change state.
    if (!TextUtils.isEmpty(action) && action.equals("android.net.conn.CONNECTIVITY_CHANGE")) {
        // If internet connection established
        if (isConnected) {
            // If didn't missed last update of data due to network issues do nothing,
            // otherwise proceed with data updating.
            final boolean missUpdateDueToNetworkIssue = sp
                    .getBoolean(MainActivity.MISS_UPDATE_DUE_TO_NETWORK_ISSUE, false);
            if (!missUpdateDueToNetworkIssue)
                return;
        }
        // If user switch off Internet connection do not proceed.
        else
            return;
    }
    // Check Boot state.
    else if (!TextUtils.isEmpty(action) && action.equals("android.intent.action.BOOT_COMPLETED")) {
        // Get stored alarm time.
        final long nextAlarmTime = PreferenceUtils.getDataLong(context,
                PreferenceUtils.KEY_ALERT_TIME_IN_MILLIS, -1);
        if (nextAlarmTime != -1) {
            // Set new alarm, as after reboot alarm was switched off.
            if (mAlarmManager == null)
                mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

            Intent alarmIntent = new Intent(context, AlarmReceiver.class);
            if (mAlarmIntent == null)
                mAlarmIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);

            // Enable boot receiver
            ComponentName receiver = new ComponentName(context, AlarmReceiver.class);
            PackageManager pm = context.getPackageManager();
            pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                    PackageManager.DONT_KILL_APP);

            final int ui = DialogSettings.getUpdateInterval(context);
            AlarmType type = ui == DialogSettings.DAILY ? AlarmType.DAILY
                    : ui == DialogSettings.WEEKLY ? AlarmType.WEEKLY : AlarmType.MONTHLY;

            mAlarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, nextAlarmTime, type.getValue(),
                    mAlarmIntent);
        }
        return;
    }
    // When alarm rise we appears in the block below.
    else {
        Logger.beep();
        Logger.beep();
        Logger.beep();
        // Calculating next alarm time.
        final Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        final int updateInterval = DialogSettings.getUpdateInterval(context);
        if (updateInterval == DialogSettings.DAILY)
            calendar.add(Calendar.DATE, 1);
        else if (updateInterval == DialogSettings.WEEKLY)
            calendar.add(Calendar.DATE, 7);
        else if (updateInterval == DialogSettings.MONTHLY)
            calendar.add(Calendar.MONTH, 1);
        else
            Logger.error("AlarmReceiver", "Unknown Update Interval.");

        // Next alarm time.
        final long nextAlarmTimeInMillis = calendar.getTimeInMillis();
        // Store next alarm time for further use.
        PreferenceUtils.storeDataLong(context, PreferenceUtils.KEY_ALERT_TIME_IN_MILLIS, nextAlarmTimeInMillis);
    }

    if (!isConnected) {
        Logger.debug("AlarmReceiver", "No Internet connection, while receiving Alarm message");
        // If no internet connecting schedule data update, as soon
        // as internet connection will be available.
        SharedPreferences.Editor ed = sp.edit();
        ed.putBoolean(MainActivity.MISS_UPDATE_DUE_TO_NETWORK_ISSUE, true);
        ed.apply();
        return;
    }

    final String cerNum = sp.getString(MainActivity.CER_NUMBER, MainActivity.EMPTY_STRING);
    final String regNum = sp.getString(MainActivity.REG_NUMBER, MainActivity.EMPTY_STRING);
    final boolean login = sp.getBoolean(MainActivity.AUTO_LOGIN, false);
    if (!login) { // If no auto login user detected.
        Logger.debug("AlarmReceiver", "Why we enter this case if no auto login users detected?");
        // Remove alarm.
        AlarmReceiver.createAlarm(context, AlarmReceiver.AlarmType.NONE);
        return;
    }

    if (TextUtils.isEmpty(cerNum) || TextUtils.isEmpty(regNum)) {
        Logger.debug("AlarmReceiver", "Why we enter this case if both data are null or empty?");
        // Remove alarm.
        AlarmReceiver.createAlarm(context, AlarmReceiver.AlarmType.NONE);
        // Remove auto login.
        SharedPreferences.Editor ed = sp.edit();
        ed.putBoolean(MainActivity.AUTO_LOGIN, false);
        ed.apply();
        return;
    }

    // Start downloading data from internet.
    Submitter submitter = new Submitter(cerNum, regNum, this);
    submitter.executeOnExecutor(Executors.newSingleThreadExecutor());
}