質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

0回答

700閲覧

このAndroidアプリのライフサイクルの説明をお願いできないでしょうか。(初心者)

Sakana4432

総合スコア4

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

0クリップ

投稿2022/11/22 09:14

編集2022/11/22 10:37

navigationで2つのフラグメント間を遷移しているようですね。間違っていたらご指摘いただけると助かります。

最近、Androidアプリの開発に興味を持ち始めた初心者です。
入門書を一通り読み終えた程度の理解です。

TensorFlowLighのサンプルプログラムを見ていたところ、プログラムの流れが全く理解できず、よろしければ解説をお願いできないでしょうか。
URL : https://github.com/tensorflow/examples.git

このアプリの機能としては、アプリを立ち上げるとカメラが起動し、オブジェクト検出を行い、ラベル付けされたオブジェクトが枠で囲われて表示されるというものです。

MainActivityと同じディレクトリに"...fragment.kt"と名前のあるファイルが2つあり、その中でオブジェクト検出等の処理を行っている訳ですが、そのプログラムとMainActivityがどのように関連付いているのかが理解できません。

解説をお願いできないでしょうか。
宜しくお願いいたします。

MainActivity.kt

1/* 2package org.tensorflow.lite.examples.objectdetection 3 4import android.os.Build 5import android.os.Bundle 6import android.widget.TextView 7import androidx.appcompat.app.AppCompatActivity 8import org.opencv.android.OpenCVLoader 9import org.tensorflow.lite.examples.objectdetection.databinding.ActivityMainBinding 10 11 12class MainActivity : AppCompatActivity() { 13 14 private lateinit var activityMainBinding: ActivityMainBinding 15 16 override fun onCreate(savedInstanceState: Bundle?) { 17 super.onCreate(savedInstanceState) 18 19 activityMainBinding = ActivityMainBinding.inflate(layoutInflater) 20 setContentView(activityMainBinding.root) 21 } 22 23 override fun onBackPressed() { 24 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) { 25 // Workaround for Android Q memory leak issue in IRequestFinishCallback$Stub. 26 // (https://issuetracker.google.com/issues/139738913) 27 finishAfterTransition() 28 } else { 29 super.onBackPressed() 30 } 31 } 32}

activity_main.xml

1<?xml version="1.0" encoding="utf-8"?> 2 3<androidx.coordinatorlayout.widget.CoordinatorLayout 4 xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:tools="http://schemas.android.com/tools" 6 xmlns:app="http://schemas.android.com/apk/res-auto" 7 android:background="@android:color/transparent" 8 android:layout_width="match_parent" 9 android:layout_height="match_parent"> 10 11 12 <RelativeLayout 13 android:layout_width="match_parent" 14 android:layout_height="match_parent" 15 android:orientation="vertical"> 16 17 <androidx.fragment.app.FragmentContainerView 18 android:id="@+id/fragment_container" 19 android:name="androidx.navigation.fragment.NavHostFragment" 20 android:layout_width="match_parent" 21 android:layout_height="match_parent" 22 android:background="@android:color/transparent" 23 android:keepScreenOn="true" 24 app:defaultNavHost="true" 25 app:navGraph="@navigation/nav_graph" 26 android:layout_marginTop="?android:attr/actionBarSize" 27 tools:context=".MainActivity"/> 28 29 <androidx.appcompat.widget.Toolbar 30 android:id="@+id/toolbar" 31 android:layout_width="match_parent" 32 android:layout_height="?attr/actionBarSize" 33 android:layout_alignParentTop="true" 34 android:background="@color/toolbar_background"> 35 36 <ImageView 37 android:layout_width="wrap_content" 38 android:layout_height="wrap_content" 39 android:src="@drawable/tfl_logo" /> 40 41 42 </androidx.appcompat.widget.Toolbar> 43 44 </RelativeLayout> 45</androidx.coordinatorlayout.widget.CoordinatorLayout>

navigation

1<?xml version="1.0" encoding="utf-8"?> 2 3<navigation 4 xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:app="http://schemas.android.com/apk/res-auto" 6 android:id="@+id/nav_graph" 7 app:startDestination="@id/permissions_fragment"> 8 9 <fragment 10 android:id="@+id/permissions_fragment" 11 android:name="org.tensorflow.lite.examples.objectdetection.fragments.PermissionsFragment" 12 android:label="PermissionsFragment" > 13 14 <action 15 android:id="@+id/action_permissions_to_camera" 16 app:destination="@id/camera_fragment" 17 app:popUpTo="@id/permissions_fragment" 18 app:popUpToInclusive="true" /> 19 20 </fragment> 21 22 <fragment 23 android:id="@+id/camera_fragment" 24 android:name="org.tensorflow.lite.examples.objectdetection.fragments.CameraFragment" 25 android:label="CameraFragment" > 26 27 28 <action 29 android:id="@+id/action_camera_to_permissions" 30 app:destination="@id/permissions_fragment" 31 app:popUpTo="@id/camera_fragment" 32 app:popUpToInclusive="true"/> 33 34 </fragment> 35</navigation>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Sakana4432

2022/11/23 15:01

回答ありがとうございます。 初めてみるものだったので、理解するまでに時間がかかってしまいました。 勉強になりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問