Skip to content

Commit

Permalink
add activity for android-specific initialization
Browse files Browse the repository at this point in the history
This is work towards #23. Unfortunately, due to javafxports/android
[#73](https://bitbucket.org/javafxports/android/issues/73/hardware-button-key-events-report)
and
[#75](https://bitbucket.org/javafxports/android/issues/75/fxactivity-does-not-call),
there is no way to control volume. However, this *should* work once #75 is
fixed.
  • Loading branch information
euclio committed Aug 6, 2015
1 parent 9db64a2 commit 5cf28a3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="javafxports.android.FXActivity"
android:name="org.gamefolk.roomfullofcats.CatsActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<meta-data android:name="main.class" android:value="org.gamefolk.roomfullofcats.RoomFullOfCatsApp" />
<meta-data android:name="main.class" android:value="org.gamefolk.roomfullofcats.CatsActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="javafxports.android.FXActivity"
android:screenOrientation="portrait">
<meta-data android:name="main.class" android:value="org.gamefolk.roomfullofcats.RoomFullOfCatsApp" />
</activity>
</application>
</manifest>
31 changes: 31 additions & 0 deletions app/src/android/java/org/gamefolk/roomfullofcats/CatsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.gamefolk.roomfullofcats;

import android.app.Activity;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;

import javafxports.android.FXActivity;

import java.util.logging.Logger;

/**
* Shim class that immediately passes control to FXActivity.
*
* We use this to perform any Android-specific initialization.
*/
public class CatsActivity extends Activity {

private static final Logger Log = Logger.getLogger(RoomFullOfCatsApp.class.getName());

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// This should work, once javafxports/android #73 and #75 are fixed.
setVolumeControlStream(AudioManager.STREAM_MUSIC);

Intent intent = new Intent(this, FXActivity.class);
startActivity(intent);
}
}

0 comments on commit 5cf28a3

Please sign in to comment.