Android Open Source - One-Button-App---Android main U I Tabs






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;
//  w w  w  . j av  a  2 s.co  m
import java.util.Timer;
import java.util.TimerTask;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.Toast;


public class mainUITabs extends TabActivity {
  public static TabHost mTabHost;
  

  public void onCreate(Bundle savedInstanceState) {
    
    super.onCreate(savedInstanceState);
    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();
          }
    
    setContentView(R.layout.tab);
      mTabHost=getTabHost();
      
      

      Resources res = getResources(); // Resource object to get Drawables
      TabHost tabHost = getTabHost();  // The activity TabHost
      TabHost.TabSpec spec;  // Reusable TabSpec for each tab
      Intent intent;  // Reusable Intent for each tab
      

      // Create an Intent to launch an Activity for the tab (to be reused)
      intent = new Intent().setClass(this, chooseImage.class); 
      intent.putExtra("username", getIntent().getStringExtra("username"));
    intent.putExtra("password", getIntent().getStringExtra("password"));
      
      // Initialize a TabSpec for each tab and add it to the TabHost
    intent = new Intent().setClass(this, oneButtons.class);
    spec = tabHost.newTabSpec("One Buttons").setIndicator("One Buttons",
                res.getDrawable(R.drawable.tab1))
            .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, chooseImage.class);    
    spec = tabHost.newTabSpec("New Reservation").setIndicator("New Reservation",
                        res.getDrawable(R.drawable.tab2))
                    .setContent(intent);
      tabHost.addTab(spec);
      

      // Do the same for the other tabs
      intent = new Intent().setClass(this, createConnection.class);
      intent.putExtra("username", getIntent().getStringExtra("username"));
    intent.putExtra("password", getIntent().getStringExtra("password"));
    
      spec = tabHost.newTabSpec("Current Reservation").setIndicator("Current Reservation",
                        res.getDrawable(R.drawable.tab3)).setContent(intent);
      tabHost.addTab(spec);
      
      

            
  }
  
  //Catch Back button event
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK) {
         AlertDialog.Builder adb = new AlertDialog.Builder(this);
              adb.setCancelable(true);
              
              adb.setNeutralButton("Yes", new DialogInterface.OnClickListener(){
                @Override
              public void onClick(DialogInterface arg0, int arg1) {
                // TODO Auto-generated method stub
                //CODE TO EXTEND RESERVATION
                  finish();
              }
              });
                
                adb.setMessage("Do you Want to Exit");
                adb.show();
                
              
              adb.setNegativeButton("No", new DialogInterface.OnClickListener(){
              
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
              // TODO Auto-generated method stub
              
                           
            }
                
              });
          return true;
      }
      return super.onKeyDown(keyCode, event);
  }

   
    // Initiating Menu XML file (menu.xml)
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.layout.mainmenu, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
 
        switch (item.getItemId())
        {
        case R.id.menu_logout:
            // Single menu item is selected do something
            // Ex: launching new activity/screen or show alert message
            Toast.makeText(getBaseContext(), "Logging out", Toast.LENGTH_SHORT).show();
            
            Android_OBAActivity.settings.edit().clear().commit();
            finish();
            return true;
 
        case R.id.menu_about:
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setMessage("VCL - One Button App v1.0 \n " +
              "This product includes software developed by : \n" +
              "the Apache Software Foundation http://www.apache.org/ \n" +
              "Android : http://developer.android.com \n" +
              "VCL : http://vcl.ncsu.edu")
                 .setCancelable(false)
                                .setNegativeButton("OK", new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int id) {
                          dialog.cancel();
                     }
                 });
          AlertDialog alert = builder.create();
          alert.show();
            return true;
 
        case R.id.menu_help:
          AlertDialog.Builder builder_help = new AlertDialog.Builder(this);
          builder_help.setMessage("=====HELP=====\n" +
              "This Application is used to reserve and launch applications at the click of a button.\n" +
              "1. The entire framework is based on the NCSU's VCL Cloud \n" +
              "2. For more information on VCL and other troubleshooting, please visit www.vcl.ncsu.edu \n" +
              "3. For troubleshooting information please consult the manual available at the above website\n" +
              "4. This application needs external 3rd party Software to launch reservations. Please install Remote Rdp and ConnectBot for Windows and Unix based reservations\n")
                 .setCancelable(false)
                                .setNegativeButton("OK", new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int id) {
                          dialog.cancel();
                     }
                 });
          AlertDialog alert_help = builder_help.create();
          alert_help.show();
            return true;
  
        default:
            return super.onOptionsItemSelected(item);
        }
    }
  
  
  
}




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