Android Open Source - Android-GTalk-Music-Status G Talk Status Application






From Project

Back to project page Android-GTalk-Music-Status.

License

The source code is released under:

GNU General Public License

If you think the Android project Android-GTalk-Music-Status 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

/***************************************************************************
 *   Copyright 2010 Scott Ferguson                                         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
package com.gtalkstatus.android;
/*from   w  w  w . ja  va 2 s .c o  m*/
import android.app.Application;
import android.content.SharedPreferences;
import android.content.Intent;
import android.content.Context;
import android.app.Notification;
import android.app.NotificationManager;

import org.jivesoftware.smack.XMPPException; 

public class GTalkStatusApplication extends Application {

    private static XMPPTransfer mGTalkConnector;
    private final static String LOG_NAME = "GTalkStatusApplication";

    public static GTalkStatusApplication sInstance = null;

    public static GTalkStatusApplication getInstance() {
        
        if (sInstance != null) {
            return sInstance;
        } else {
            return new GTalkStatusApplication();
        }
    }

    @Override
    public void onCreate() {

        sInstance = this;

        try {
            updateConnection();
        } catch (Exception e) {
            // Do nothing here.  If there is an error when attempting to connect, we'll want
            // to catch it when the user tries playing music.
        }
    }

    @Override
    public void onTerminate() {

        mGTalkConnector.disconnect();

        super.onTerminate();
    }

    public void startService(Context aContext, Intent aIntent) {

        Intent serviceIntent = new Intent(this, GTalkStatusUpdater.class);
        serviceIntent.setAction(aIntent.getAction());
        serviceIntent.putExtras(aIntent);

        aContext.startService(serviceIntent);
    }

    public void updateConnection() throws XMPPException {

        if (mGTalkConnector != null) {
            mGTalkConnector.disconnect();
        }

        SharedPreferences settings = getSharedPreferences("GTalkStatusPrefs", 0);
        String username = settings.getString("USERNAME", "");
        String password = settings.getString("PASSWORD", "");

        mGTalkConnector = new XMPPTransfer(username, password);
    }

    public XMPPTransfer getConnector() {

        return mGTalkConnector;
    }
  
}




Java Source Code List

com.gtalkstatus.android.GTalkEditCredentials.java
com.gtalkstatus.android.GTalkStatusActivity.java
com.gtalkstatus.android.GTalkStatusApplication.java
com.gtalkstatus.android.GTalkStatusCurrentModel.java
com.gtalkstatus.android.GTalkStatusIntentReceiver.java
com.gtalkstatus.android.GTalkStatusNotifier.java
com.gtalkstatus.android.GTalkStatusSettingsActivity.java
com.gtalkstatus.android.GTalkStatusUpdater.java
com.gtalkstatus.android.XMPPTransfer.java