2.7 KiB
2.7 KiB
#安卓
需要在AndroidManifest.xml中,完成activity相关的添加,其中theme主题,选择的是 Theme.NoTitleBar
无标题
<application>
<activity android:name=".SurveyMonkey_SDK_Activity"
android:label="Simple Activity"
android:theme="@android:style/Theme.NoTitleBar"/>
</application>
添加后的文本样式:
然后,在 Activity活动类的onCreate中,添加以下逻辑,处理透明化相关
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); // 无触摸
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getWindow().setBackgroundDrawableResource(android.R.color.transparent); // 设置透明背景
样式效果:
提供给外部调用的,是一个static静态函数;
需要注意的是,如果包含 JSONObject
结构体的数据,是需要跟随 throw异常监听 JSONException
public static void launchActivity(Activity context,String hash,JSONObject jsonStr,boolean _isResponse,boolean _getResponse,String _Response_GameObject_Str,String _Response_Function_Str) throws JSONException
{
SURVEY_HASH_Str = hash;
survey_json_Str = jsonStr;
Response_GameObject_Str = _Response_GameObject_Str;
Response_Function_Str = _Response_Function_Str;
isResponse = _isResponse;
getResponse = _getResponse;
Intent intent = new Intent(context, SurveyMonkey_SDK_Activity.class);
context.startActivity(intent);
}
外部调用的,相关逻辑,这里是提取到,unity相关的Activity,作为父活动,调用,创建即可
Activity activity = UnityActivity.getActivity();
boolean _isResponse = true;
if(_Response_Function_Str == null || _Response_Function_Str.isEmpty() || _Response_GameObject_Str == null || _Response_GameObject_Str.isEmpty())
{
_isResponse = false;
}
SurveyMonkey_SDK_Activity.launchActivity(activity,SURVEY_HASH,jsonObject_surveyMonkey,_isResponse,_getResponse,_Response_GameObject_Str,_Response_Function_Str);
全局检索UnityActivity.java
可以看到,具体逻辑: