前提
startActivityで出るワーニングの指摘内容が分からず困っています。
私および周りのAndroid / java の組込み経験は、かなり浅いです。
他環境の組込み経験はそれなりに有ります。
実現したいこと
画面遷移はできています。遷移先画面での操作も今のところ問題なくできます。
ですが、企業向けアプリ開発ですのでワーニングは全て除去したいのです。
よろしくお願いいたします。
発生している問題・エラーメッセージ
ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@XXXXX
該当のソースコード
AndroidManifest.xml
1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 package="com.example.sample"> 5 6 <application 7 android:allowBackup="true" 8 android:dataExtractionRules="@xml/data_extraction_rules" 9 android:fullBackupContent="@xml/backup_rules" 10 android:icon="@mipmap/ic_launcher" 11 android:label="@string/app_name" 12 android:roundIcon="@mipmap/ic_launcher_round" 13 android:supportsRtl="true" 14 android:theme="@style/Theme.Sample" 15 tools:targetApi="31"> 16 <activity 17 android:name=".MainActivity" 18 android:exported="true"> 19 <intent-filter> 20 <action android:name="android.intent.action.MAIN" /> 21 22 <category android:name="android.intent.category.LAUNCHER" /> 23 </intent-filter> 24 </activity> 25 <activity 26 android:name=".NextActivity" 27 android:exported="false"> 28 </activity> 29 </application> 30 31</manifest>
activity_main.xml
1<?xml version="1.0" encoding="utf-8"?> 2<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context=".MainActivity"> 8 9 <TextView 10 android:id="@+id/txtHello" 11 android:layout_width="wrap_content" 12 android:layout_height="wrap_content" 13 android:text="Hello World!" 14 app:layout_constraintBottom_toBottomOf="parent" 15 app:layout_constraintStart_toStartOf="parent" 16 app:layout_constraintEnd_toEndOf="parent" 17 app:layout_constraintTop_toTopOf="parent" /> 18 19 <Button 20 android:id="@+id/btnNext" 21 android:layout_width="wrap_content" 22 android:layout_height="wrap_content" 23 android:text="NEXT" 24 app:layout_constraintBottom_toBottomOf="parent" 25 app:layout_constraintStart_toEndOf="@id/txtHello" 26 app:layout_constraintEnd_toEndOf="parent" 27 app:layout_constraintTop_toBottomOf="@id/txtHello" /> 28 29 <Button 30 android:id="@+id/btnExit" 31 android:layout_width="wrap_content" 32 android:layout_height="wrap_content" 33 android:text="EXIT" 34 app:layout_constraintBottom_toBottomOf="parent" 35 app:layout_constraintStart_toStartOf="parent" 36 app:layout_constraintEnd_toStartOf="@id/txtHello" 37 app:layout_constraintTop_toBottomOf="@id/txtHello" /> 38 39</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
1package com.example.sample; 2 3import androidx.appcompat.app.AppCompatActivity; 4 5import android.content.Intent; 6import android.os.Bundle; 7import android.widget.Button; 8 9public class MainActivity extends AppCompatActivity{ 10 11 @Override 12 protected void onCreate( Bundle savedInstanceState ){ 13 super.onCreate( savedInstanceState ); 14 setContentView( R.layout.activity_main ); 15 16 // (ボタン)NEXT 17 findViewById(R.id.btnNext).setOnClickListener( view -> startActivity( new Intent( this, NextActivity.class ) ) ); 18 19 // (ボタン)EXIT 20 findViewById(R.id.btnExit).setOnClickListener( view -> finishAndRemoveTask() ); 21 } 22}
activity_next.xml
1<?xml version="1.0" encoding="utf-8"?> 2<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:background="#20FF0000" 8 tools:context=".NextActivity"> 9 10 <TextView 11 android:id="@+id/txtNext" 12 android:layout_width="wrap_content" 13 android:layout_height="wrap_content" 14 android:text="Next Acivity." 15 app:layout_constraintBottom_toBottomOf="parent" 16 app:layout_constraintStart_toStartOf="parent" 17 app:layout_constraintEnd_toEndOf="parent" 18 app:layout_constraintTop_toTopOf="parent" /> 19 20 <Button 21 android:id="@+id/btnBack" 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:text="BACK" 25 app:layout_constraintBottom_toBottomOf="parent" 26 app:layout_constraintStart_toStartOf="parent" 27 app:layout_constraintEnd_toStartOf="@id/txtNext" 28 app:layout_constraintTop_toBottomOf="@id/txtNext" /> 29 30</androidx.constraintlayout.widget.ConstraintLayout>
NextActivity.java
1package com.example.sample; 2 3import android.content.Intent; 4import android.os.Bundle; 5 6import androidx.appcompat.app.AppCompatActivity; 7 8public class NextActivity extends AppCompatActivity{ 9 10 @Override 11 protected void onCreate( Bundle savedInstanceState ){ 12 super.onCreate( savedInstanceState ); 13 setContentView( R.layout.activity_next ); 14 15 // (ボタン)BACK 16 findViewById(R.id.btnBack).setOnClickListener( view -> finish() ); 17 } 18}
試したこと
this を getApplicationContext() に変えてみたぐらいです。。
補足情報(FW/ツールのバージョンなど)
遷移元はアプリ起動時に最初に表示されるMainのActivityで、
まだ"Hello World!"とボタン2つしか配置していません。
遷移先画面もテキスト1つとボタン2つのみです。
ワーニングが出るタイミングですが
遷移元画面の onPause() 開始後 ~
遷移先画面の onCreate() 開始前 までの間です。
また、最初の1回だけではなく
遷移先画面と行ったり来たりを繰返す度に上記タイミングで毎回出ます。
【環境】
Chipmunk (2021.2.1)
java
compileSdk 32
以上です。
よろしくお願いいたします。
回答2件