Advertisement
Guest User

PhoneGap Activity.java file

a guest
Jun 22nd, 2012
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. package org.yourgroup.yourname;
  2.  
  3. //import android.app.Activity;
  4. import android.os.Bundle;
  5. import org.apache.cordova.*;
  6. import android.view.WindowManager; // For Full screen
  7. import android.view.Menu; // For the menu
  8. import android.view.MenuItem; // For the menu
  9.  
  10. public class HelloCordovaActivity extends DroidGap {
  11.     /** Called when the activity is first created. */
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         // The lines to make the app go Full Screen
  16.         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  17.                 WindowManager.LayoutParams.FLAG_FULLSCREEN |
  18.                 WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  19.         // The line to add the splashscreen
  20.         super.setIntegerProperty("splashscreen", R.drawable.splash);
  21.         super.loadUrl("file:///android_asset/www/index.html", 3000); // I used 3000 for mine.
  22.         // (..index.html", 3000 ) specifies the miliseconds that the splashscreen will stay up
  23.         // before the app starts.
  24.     }    
  25.  
  26.     // Declaring the Menu options
  27.     @Override
  28.     public boolean onCreateOptionsMenu(Menu menu)
  29.     {
  30.         super.onCreateOptionsMenu(menu);
  31.         int base = Menu.FIRST;
  32.         // Group, item id, order, title
  33.         menu.add(base,base,base,"Quit");
  34.         menu.add(base,base,base,"Reload");
  35.         return true;
  36.     }
  37.  
  38.     //handle menu item selection
  39.     public boolean onOptionsItemSelected(MenuItem item)
  40.     {
  41.         if (item.hasSubMenu() == false)
  42.         {
  43.             if("Quit"==item.getTitle()) {
  44.                 finish();
  45.             }
  46.             if("Reload"==item.getTitle()) {
  47.                super.loadUrl("file:///android_asset/www/index.html");
  48.             }
  49.         }
  50.         return true;
  51.     }
  52.    
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement