Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
presentActivity
<?xml version="1.0" encoding="utf-8"?>
<manifest android:versionCode="1" android:versionName="0.0.1" android:installLocation="auto" package="air.com.ludia.gamesample2"
xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="@string/app_name" android:icon="@drawable/icon" android:enabled="true" android:debuggable="true" android:hardwareAccelerated="false">
<activity android:theme="@style/Theme.NoShadow" android:label="@string/app_name" android:name=".AppEntry" android:excludeFromRecents="false" android:launchMode="singleTask" android:screenOrientation="user" android:configChanges="keyboardHidden|orientation|screenSize" android:windowSoftInputMode="stateHidden|adjustResize">
<meta-data android:name="namespaceVersion" android:value="3.9" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="autoOrients" android:value="true" />
<meta-data android:name="fullScreen" android:value="true" />
<meta-data android:name="uniqueappversionid" android:value="7abbdeb0-eebe-40a9-a707-c407ad0f1f08" />
<meta-data android:name="initialcontent" android:value="sessionm-example-1.0.0-SNAPSHOT.swf" />
<meta-data android:name="containsVideo" android:value="false" />
</activity>
<activity android:theme="@*android:style/Theme.Translucent" android:name="ludia.sessionm.PresentActivityActivity" />
<activity android:theme="@*android:style/Theme.Black.NoTitleBar.Fullscreen" android:name="com.sessionm.ui.SessionMActivity" android:configChanges="keyboard|orientation|screenSize" android:windowSoftInputMode="adjustPan" />
<receiver android:name="com.sessionm.api.ConnectionReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<meta-data android:name="com.sessionm.appid" android:value="3f07ab1fa36c7232fd7f8d9c39abd4ba77336fe3" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true" />
</manifest>
package ludia.sessionm;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.sessionm.api.ActivityListener;
import com.sessionm.api.BaseActivity;
import com.sessionm.api.SessionM;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Map;
public class PresentActivityActivity extends BaseActivity{
private static final String TAG = "ludia.sessionm.PresentActivityActivity";
public static String ACTIVITY_PRESENTED = "ACTIVITY_PRESENTED";
public static String ACTIVITY_DISMISSED = "ACTIVITY_DISMISSED";
public static String ACTIVITY_UNAVAILABLE = "ACTIVITY_UNAVAILABLE";
public static String USER_ACTION = "USER_ACTION";
private boolean calledPresent;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
Log.d(TAG, "PresentActivityActivity.onCreate()");
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "PresentActivityActivity.onNewIntent()");
}
@Override
protected void onStart() {
super.onStart();
Log.d(TAG, "PresentActivityActivity.onStart()");
}
@Override
protected void onRestart() {
super.onRestart();
Log.d(TAG, "PresentActivityActivity.onRestart()");
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "PresentActivityActivity.onResume()");
if (!calledPresent) {
sessionM.presentActivity(type);
calledPresent = true;
} else {
finish();
}
}
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "PresentActivityActivity.onPause()");
}
@Override
protected void onStop() {
super.onStop();
Log.d(TAG, "PresentActivityActivity.onStop()");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "PresentActivityActivity.onDestroy()");
}
@Override
public void onPresented(SessionM sessionM) {
Log.d(TAG, "PresentActivityActivity.onPresented()");
SessionMExtension.context.dispatchStatusEventAsync(ACTIVITY_PRESENTED, "");
}
@Override
public void onDismissed(SessionM sessionM) {
Log.d(TAG, "PresentActivityActivity.onDismissed()");
SessionMExtension.context.dispatchStatusEventAsync(ACTIVITY_DISMISSED, "");
// finish();
}
@Override
public void onUnavailable(SessionM sessionM) {
Log.d(TAG, "PresentActivityActivity.onUnavailable()");
SessionMExtension.context.dispatchStatusEventAsync(ACTIVITY_UNAVAILABLE, "");
}
@Override
public void onUserAction(SessionM sessionM, UserAction userAction, Map<String, String> stringStringMap) {
Log.d(TAG, "PresentActivityActivity.onUserAction()");
super.onUserAction(sessionM, userAction, stringStringMap);
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject();
jsonObject.put("userAction", userAction.toString());
jsonObject.put("achievementName", stringStringMap.get(ActivityListener.UserActionAchievementNameKey));
jsonObject.put("sponsorContentName", stringStringMap.get(ActivityListener.UserActionSponsorContentNameKey));
jsonObject.put("pageName", stringStringMap.get(ActivityListener.UserActionPageNameKey));
jsonObject.put("rewardName", stringStringMap.get(ActivityListener.UserActionRewardNameKey));
}
catch (JSONException e) {
jsonObject = null;
}
finally {
if(jsonObject != null) {
SessionMExtension.context.dispatchStatusEventAsync(USER_ACTION, jsonObject.toString());
}
}
}
}
package ludia.sessionm.functions;
import android.app.Activity;
import android.content.Intent;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
import ludia.sessionm.PresentActivityActivity;
import ludia.sessionm.SessionMExtension;
public class PresentActivityFunction implements FREFunction {
@Override
public FREObject call(FREContext freContext, FREObject[] freObjects)
{
SessionMExtension.log("PresentActivityFunction.call()");
String type = readActivityType(freObjects);
Activity activity = freContext.getActivity();
Intent intent = new Intent(activity.getApplicationContext(), PresentActivityActivity.class);
intent.putExtra("ACT_TYPE", type);
try {
activity.startActivity(intent);
}
catch (Exception e) {
SessionMExtension.logError("Error: " + e.toString());
}
return null;
}
private String readActivityType(FREObject[] freObjects)
{
String action = null;
try
{
action = freObjects[0].getAsString();
}
//Exception of type FREInvalidObjectException, FREWrongThreadException or FRETypeMismatchException
catch (Exception e)
{
SessionMExtension.logError("Couldn't retrieve action : " + e.getMessage());
}
finally
{
return action;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment