Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 1.82 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Can I run an Activity before running libgdx?
  2. public class MyActivity extends AndroidApplication {
  3.     public void onCreate (android.os.Bundle savedInstanceState) {
  4.         super.onCreate(savedInstanceState);
  5.         setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  6.  
  7.         Intent myIntent = new Intent(MyActivity.this, StartActivity.class);
  8.         startActivity(myIntent);
  9.  
  10.         initialize(new MyGame(), false); //run libgdx
  11.     }
  12. }
  13.        
  14. public class StartActivity extends Activity {
  15.     /** Called when the activity is first created. */
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.  
  20.         TextView text = new TextView(this);
  21.         text.setText("Hello World, Android");
  22.         setContentView(text);
  23.  
  24.         try {
  25.             Thread.sleep(7000);
  26.         }
  27.         catch (InterruptedException e) {};
  28.         finish();
  29.         return;
  30.     }
  31. }
  32.        
  33. Intent i = new Intent(this, MyActivity.class);
  34. startActivity(i);
  35.        
  36. public class BluetoothActivity extends Activity {
  37.     @Override
  38.     public void onCreate(Bundle savedInstanceState) {
  39.         super.onCreate(savedInstanceState);
  40.         setContentView(R.layout.bluetoothsettings);
  41.         Button startGame = (Button)findViewById(R.id.btnStartGame);
  42.  
  43.         // handle set start click
  44.         startGame.setOnClickListener(new OnClickListener() {
  45.             @Override
  46.             public void onClick(View v) {
  47.                 Intent intent = new Intent(BluetoothActivity.this, GameActivity.class);
  48.                 BluetoothActivity.this.startActivity(intent);
  49.             }
  50.         });
  51.     }
  52. }
  53.        
  54. <activity android:name=".BluetoothActivity">
  55.   <intent-filter>
  56.     <action android:name="android.intent.action.MAIN" />
  57.     <category android:name="android.intent.category.LAUNCHER" />
  58.   </intent-filter>
  59. </activity>