Android Open Source - One-Button-App---Android Android_ O B A Activity






From Project

Back to project page One-Button-App---Android.

License

The source code is released under:

Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (...

If you think the Android project One-Button-App---Android 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 edu.cc.oba;
/* www  .ja v  a  2  s.co  m*/
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import android.net.ConnectivityManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

//hello github

public class Android_OBAActivity extends Activity {
  
  public static SharedPreferences settings=null;  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ConnectivityManager cm=null;
        
        try{
      cm = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
    }
    catch(NullPointerException e)
    {
      Toast.makeText(getBaseContext(), "No Internet ConnectioN Found", 4).show();
      finish();
    }
        
       try{ if( cm.getActiveNetworkInfo().isConnectedOrConnecting()==false)
        {
          Toast.makeText(getBaseContext(), "No Internet ConnectioN Found", 4).show();
        }}
       catch(NullPointerException e)
          {
          Toast.makeText(getBaseContext(), "No Internet ConnectioN Found", 4).show();
          finish();
            
          }
    
        
        
        settings = getPreferences(0);
        
        
        if(settings.contains("user"))
        {
          String username=settings.getString("user", "");
          String password=settings.getString("pass", "");
          TestOBA.getUserObject(username, password);
          Intent myIntent = new Intent(Android_OBAActivity.this, mainUITabs.class);
        myIntent.putExtra("username", username);
        myIntent.putExtra("password", password);
        Android_OBAActivity.this.startActivity(myIntent);  
          
        }
        
        else{
        
        final EditText user_name=(EditText) this.findViewById(R.id.username);
      final EditText pass_word=(EditText) this.findViewById(R.id.password); 
      
      //TEST CODE
      
      final String username=user_name.getText().toString();
        final String password=pass_word.getText().toString();
              
        //Stored user name and pass in shared prefs . need more security ?
      
    
    //
      
        final Button logIn= (Button) this.findViewById(R.id.Login);
        
    
    
        logIn.setOnClickListener(new OnClickListener(){

      @Override
      public void onClick(View arg0) {
        
            
            final String username=user_name.getText().toString();
            final String password=pass_word.getText().toString();
            boolean auth=true;
            try{
              TestOBA.getUserObject(username, password);
              auth=true;
                          }
            catch(NullPointerException e)
            {
              Toast.makeText(getBaseContext(), "Check your Password", 4).show();
              auth=false;
              
            }
            
            if(auth==true){
            settings.edit().putString("user", username).commit();
            settings.edit().putString("pass", password).commit(); 
            
            Log.i("SP", settings.getAll().toString());
                      
        Intent myIntent = new Intent(Android_OBAActivity.this, mainUITabs.class);
        myIntent.putExtra("username", username);
        myIntent.putExtra("password", password);
        Android_OBAActivity.this.startActivity(myIntent);  
        
            }
            
      }
        
        });
        
        }
    
    
    
    
    }
}




Java Source Code List

edu.cc.oba.Android_OBAActivity.java
edu.cc.oba.Android_OBAActivity.java
edu.cc.oba.ConnectWithPass.java
edu.cc.oba.ConnectWithPass.java
edu.cc.oba.CopyOfcreateConnection.java
edu.cc.oba.CopyOfcreateConnection.java
edu.cc.oba.ImageDB.java
edu.cc.oba.TestOBA.java
edu.cc.oba.TestOBA.java
edu.cc.oba.chooseImage.java
edu.cc.oba.chooseImage.java
edu.cc.oba.createConnection.java
edu.cc.oba.createConnection.java
edu.cc.oba.mainUITabs.java
edu.cc.oba.mainUITabs.java
edu.cc.oba.oneButtons.java
edu.cc.oba.oneButtons.java
org.apache.http.examples.client.ClientAbortMethod.java
org.apache.http.examples.client.ClientAuthentication.java
org.apache.http.examples.client.ClientChunkEncodedPost.java
org.apache.http.examples.client.ClientConnectionRelease.java
org.apache.http.examples.client.ClientCustomContext.java
org.apache.http.examples.client.ClientCustomSSL.java
org.apache.http.examples.client.ClientEvictExpiredConnections.java
org.apache.http.examples.client.ClientExecuteDirect.java
org.apache.http.examples.client.ClientExecuteProxy.java
org.apache.http.examples.client.ClientExecuteSOCKS.java
org.apache.http.examples.client.ClientFormLogin.java
org.apache.http.examples.client.ClientGZipContentCompression.java
org.apache.http.examples.client.ClientInteractiveAuthentication.java
org.apache.http.examples.client.ClientKerberosAuthentication.java
org.apache.http.examples.client.ClientMultiThreadedExecution.java
org.apache.http.examples.client.ClientPreemptiveBasicAuthentication.java
org.apache.http.examples.client.ClientPreemptiveDigestAuthentication.java
org.apache.http.examples.client.ClientProxyAuthentication.java
org.apache.http.examples.client.ClientWithResponseHandler.java
org.apache.http.examples.conn.ManagerConnectDirect.java
org.apache.http.examples.conn.ManagerConnectProxy.java
org.apache.http.examples.conn.OperatorConnectDirect.java
org.apache.http.examples.conn.OperatorConnectProxy.java
org.apache.http.examples.entity.mime.ClientMultipartFormPost.java
org.kxml2.wap.WbxmlParser.java
org.kxml2.wap.WbxmlSerializer.java
org.kxml2.wap.wml.Wml.java
org.xmlrpc.android.Base64Coder.java
org.xmlrpc.android.IXMLRPCSerializer.java
org.xmlrpc.android.MethodCall.java
org.xmlrpc.android.Tag.java
org.xmlrpc.android.XMLRPCClient.java
org.xmlrpc.android.XMLRPCCommon.java
org.xmlrpc.android.XMLRPCException.java
org.xmlrpc.android.XMLRPCFault.java
org.xmlrpc.android.XMLRPCSerializable.java
org.xmlrpc.android.XMLRPCSerializer.java
org.xmlrpc.android.XMLRPCServer.java