我在 Android 上使用 Unity,当视图处于全屏模式时它可以工作,但是当我将它变成子视图时,屏幕不显示任何内容。
它作为全屏工作:
Intent intent = new Intent(this, UnityPlayerActivity.class);
intent.putExtra("arguments", "data from android");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这些问题也没有答案:
我已经尝试了他们的解决方案,但似乎都没有奏效。
在android studio中将Unity场景显示为子视图
https://gamedev.stackexchange.com/questions/134347/android-black-screen-with-unity-app-in-subview
我当前的 MainActivity/Unity 清单:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
m_UnityPlayer = new UnityPlayer(this);
int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
m_UnityPlayer.init(glesMode, trueColor8888);
setContentView(R.layout.activity_main);
FrameLayout layout = (FrameLayout) findViewById(R.id.frameLayout2);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layout.addView(m_UnityPlayer.getView(), 0, lp);
}
Run Code Online (Sandbox Code Playgroud)
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category …
Run Code Online (Sandbox Code Playgroud) 我正在使用 exoplayer 2,并打开了重复模式,这意味着它会在视频播放结束时继续播放。但是,在视频结束并再次播放后,它会不断重新缓冲(重新加载视频)。我如何防止这种情况发生?
player = new SimpleExoPlayer.Builder(mContext).build();
player.setPlayWhenReady(false);
player.setRepeatMode(Player.REPEAT_MODE_ONE);
Run Code Online (Sandbox Code Playgroud)
编辑1:
尝试过使用 LoopingMediaSource,但不确定我是否做得正确?因为它在自动重播视频时仍然会重新缓冲。
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(mContext,
Util.getUserAgent(mContext, "yourApplicationName"));
Uri uri = Uri.parse(mUrl);
MediaSource videoSource =
new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(videoSource);
player.prepare(loopingMediaSource);
Run Code Online (Sandbox Code Playgroud) 我正在关注这个关于使用 MVVM 和 Retrofit 的教程
https://medium.com/@ronkan26/viewmodel-using-retrofit-mvvm-architecture-f759a0291b49
用户将 MutableLiveData 放置在 Repository 类中的位置:
public class MovieRepository {
private static final ApiInterface myInterface;
private final MutableLiveData<EntityMovieOutputs> listOfMovies = new MutableLiveData<>();
private static MovieRepository newsRepository;
public static MovieRepository getInstance(){
if (newsRepository == null){
newsRepository = new NewsRepository();
}
return movieRepository;
}
public MovieRepository(){
myInterface = RetrofitService.getInterface();
}
Run Code Online (Sandbox Code Playgroud)
I'm building a simple app and what I noticed is my repository class is quickly being filled with a lot of MutableLiveData objects. Is this actually the …
我正在为我的 Alexa Skill 使用 Lambda 函数。对于我的启动意图,我查询 DynamoDB 并返回一个字符串,我首先想要将其转换为 QRCode,然后我想将其作为图像内的图像返回到 Alexa 设备。responseBuilder
Alexa 可以很好地显示来自外部 url 的图像,例如
const rabbitImage = "https://i.imgur.com/U6eF0oH.jpeg";
return responseBuilder
.speak(say)
.withStandardCard("Welcome to Alexa", "description", rabbitImage, rabbitImage)
.reprompt('try again, ' + say)
.getResponse();
Run Code Online (Sandbox Code Playgroud)
但我陷入了如何将 QRCode 发送回 Alexa 设备的问题responseBuilder
。
我正在使用一个nodejs
名为 的库qrcode
,它可以将字符串转换为 QRCode,然后转换为base64
.
https://www.npmjs.com/package/qrcode
但根据 Alexa 文档,"card" aka image
向用户发送 , 时它必须是一个 url。
The Alexa Skills Kit provides different types of cards:
A Standard card also displays plain text, but …
Run Code Online (Sandbox Code Playgroud) 在我取消选中它们或单击组中的另一个 RadioButton 后,我的 RadioGroup 中的 RadioButton 会留下一个黑色的选中圆圈。我如何防止这种情况发生?
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test"
android:textAlignment="textStart"
android:layoutDirection="rtl"
android:layout_gravity="start"
android:background="?android:selectableItemBackground"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textStart"
android:layoutDirection="rtl"
android:layout_gravity="start"
android:background="?android:selectableItemBackground"/>
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
发生在我的 API 19 真实设备上,而不是我的 API 27
编辑:_________________________________________________
曾尝试使用不起作用的自定义选择器
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/qrmenu_toolbar"
android:orientation="vertical">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Resume"
android:layoutDirection="rtl"
android:layout_gravity="start"
android:drawablePadding="12dp"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingEnd="16dp"
android:paddingBottom="12dp"
app:drawableLeftCompat="@drawable/ic_resume"
android:button="@drawable/radiobutton_selector"
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_checked" android:state_checked="true" />
<item android:drawable="@drawable/radio_unchecked" android:state_checked="false" />
</selector>
Run Code Online (Sandbox Code Playgroud)
主题:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorBlack</item>
<item …
Run Code Online (Sandbox Code Playgroud) 我正在关注关于在 SceneView 中将光添加到节点的谷歌开发人员指南:
https://developers.google.com/sceneform/develop/build-scene
Light spotLightYellow =
Light.builder(this, Light.Type.FOCUSED_SPOTLIGHT)
.setColor(new Color(android.graphics.Color.YELLOW))
.setShadowCastingEnabled(true)
.build();
Run Code Online (Sandbox Code Playgroud)
但是它似乎对我的渲染模型没有任何作用。
还有什么我想念的吗?
ModelRenderable.builder()
.setSource(
this,
Uri.parse(card)
)
.build()
.thenAccept(
modelRenderable -> {
node.setParent(scene);
node.setLocalPosition(vector3);
node.setLocalScale(new Vector3(1.4f, 1.4f, 1.4f));
node.setName("Test");
Light light =
Light.builder(Light.Type.FOCUSED_SPOTLIGHT)
.setColor(new Color(android.graphics.Color.YELLOW))
.setShadowCastingEnabled(true)
.build();
node.setLight(light);
node.setRenderable(modelRenderable);
})
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load Fox renderable" + throwable, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
Run Code Online (Sandbox Code Playgroud) 我尝试对 API 端点进行改造调用,但它返回了400 error
,但是我的 curl 请求工作得很好。我似乎无法发现错误,有人可以仔细检查我的工作,看看我在哪里犯了错误吗?
有效的 curl 调用:
curl --request POST https://connect.squareupsandbox.com/v2/payments \
--header "Content-Type: application/json" \
--header "Authorization: Bearer accesstoken112233" \
--header "Accept: application/json" \
--data '{
"idempotency_key": "ab2a118d-53e2-47c6-88e2-8c48cb09bf9b",
"amount_money": {
"amount": 100,
"currency": "USD"},
"source_id": "cnon:CBASEITjGLBON1y5od2lsdxSPxQ"}'
Run Code Online (Sandbox Code Playgroud)
我的改造电话:
public interface IMakePayment {
@Headers({
"Accept: application/json",
"Content-Type: application/json",
"Authorization: Bearer accesstoken112233"
})
@POST(".")
Call<Void> listRepos(@Body DataDto dataDto);
}
Run Code Online (Sandbox Code Playgroud)
DataDto 类:
public class DataDto {
private String idempotency_key;
private String amount_money;
private String source_id;
public DataDto(String idempotency_key, String …
Run Code Online (Sandbox Code Playgroud) 我正在按照 Kotlin 教程学习 Dagger Hilt 进行依赖注入。教程使用
class MainActivity: AppCompatActivity() {
private val viewModel: TestViewModel by viewModels()
}
Run Code Online (Sandbox Code Playgroud)
在 MainActivity 中注入视图模型。
它需要依赖:implementation "androidx.activity.activity-ktx:1.1.0"
才能这样做。
我正在尝试学习 Java 中的 hilt,所以我不确定将视图模型注入到我的活动中的 Java 等效项是什么。
这是不正确的并且不起作用
@Inject
private TestViewModel testViewModel;
Run Code Online (Sandbox Code Playgroud)
并使用
testViewModel = new ViewModelProvider(this).get(TestViewModel.class);
看起来不像依赖注入。
Java中的相当于什么by viewModels()
?
在旧的 logcat 中,我所要做的就是在搜索栏中输入我的包名称。
例如com.dave.mynewapp
但现在,当您输入包名称时,它会每秒不断地显示日志消息,我不需要这让调试变得困难。
现在,当出现新日志时,光标不会自动向下滚动,这使得它更加令人沮丧
我可以通过输入活动名称来过滤它...例如MainActivity
,但是输入我登录的每个类名称变得非常烦人。
有没有办法获取我手动创建的所有日志,但忽略上图中的混乱?
2023 年 10 月更新:
Android Studio 长颈鹿 | 2022.3.1 不再向用户发送所有这些无用日志的垃圾邮件
我的问题是我的自定义 alertdialog 类没有正确显示软键盘。我正在使用
SettingsDialog settingsDialog = new SettingsDialog(MainActivity.this);
settingsDialog.show();
Run Code Online (Sandbox Code Playgroud)
并且软键盘没有显示。我已经按照其他 stackoverflow 的答案来显示键盘... Show soft keyboard for dialog
如果我不使用自定义类,它会起作用
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
mBuilder.setView(R.layout.alertdialog_settings);
AlertDialog alertDialog = mBuilder.create();
alertDialog.show();
Run Code Online (Sandbox Code Playgroud)
但是,当使用自定义 AlertDialog 类时,我似乎无法获得与上图相同的结果
我试过手动显示键盘
SettingsDialog settingsDialog = new SettingsDialog(MainActivity.this);
settingsDialog.show();
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm != null){
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
Run Code Online (Sandbox Code Playgroud)
然而,它显示了alertdialog 后面的键盘,并且不会产生与AlertDialog Builder 相同的效果。
如何使用自定义 AlertDialog 显示软键盘以具有使用 AlertDialog Builder 的输出?
编辑:
我也尝试在 AlertDialog 的 onCreate 方法中手动显示它
public class SettingsDialog extends AlertDialog {
public SettingsDialog(@NonNull Context context, String subName) {
super(context);
this.mContext …
Run Code Online (Sandbox Code Playgroud) android ×9
android-mvvm ×1
arcore ×1
aws-lambda ×1
dagger-hilt ×1
exoplayer ×1
exoplayer2.x ×1
java ×1
kotlin ×1
node.js ×1
retrofit2 ×1
sceneform ×1
sceneview ×1
square ×1