为什么StartActivity(intent)失败? logcat show W / ActivityThread:handleWindowVisibility:令牌android.os.BinderProxy @]没有活动>

问题描述 投票:-1回答:2

我只想问为什么StartActivity(intent)失败?然后logcat显示:

D/AddPhotosFragment: categoryDesignID: ClothingDesign
D/EGL_emulation: eglMakeCurrent: 0x7ea0c3349a00: ver 2 0 (tinfo 0x7ea19df7cea0)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@15c2c02
D/CategoryDetailRecyclerViewActivity: Intent:Intent {  } 
D/CategoryDetailRecyclerViewActivity: categoryDesignID: null

AddPhotosFragment.kt

//Upload images button
upload_imgs_button.setOnClickListener {
    Log.d(TAG, "uploadImgsPath: $uploadImgsPath");
    //Upload images to firebase storage
    if (uploadImgsPath != null) {

        var count = imagesList.size
        for (uriForUpload in imagesList) {
            val uri = Uri.parse(uriForUpload)
            val imgNameUUID = UUID.randomUUID().toString()
            val withAppendedPath =
                Uri.withAppendedPath(uri, imgNameUUID).toString()
            var imgFileRef = uploadImgsPath!!.child(withAppendedPath)
            imgFileRef.putFile(uri)
                .continueWithTask {
                    if (!it.isSuccessful) {
                        it.exception?.let {
                            throw it
                        }
                    }
                    imgFileRef.downloadUrl
                }.addOnCompleteListener {
                    if (it.isSuccessful) {
                        var uriForDownload = it.result.toString()
                        Log.d(TAG, "uriForDownload:$uriForDownload ");
                        downloadImagesUriList.add(uriForDownload)
                        count--
                        if (count == 0) {
                            Log.d(
                                TAG,
                                "downloadImagesUriList:$downloadImagesUriList "
                            );
                            var uuidOfGroupId = UUID.randomUUID().toString()
                            var uploadedImages = UploadedImages(
                                categoryDesignID,
                                user!!.uid,
                                downloadImagesUriList,
                                Timestamp.now(),
                                uuidOfGroupId,
                                user!!.photoUrl.toString(),
                                user!!.displayName
                            )
                            Log.d(TAG, "uploadedImages:$uploadedImages ");
                            //Save uploaded images path info to firestore
                            firestore.collection("uploadedImages")
                                .document(uuidOfGroupId)
                                .set(uploadedImages)
                                .addOnSuccessListener {
                                    Toast.makeText(
                                        context,
                                        "Upload successful",
                                        Toast.LENGTH_LONG
                                    ).show()
                                    //TODO Show RecyclerView
                                    var intent = Intent(
                                        context,
                                        CategoryDetailRecyclerViewActivity::class.java
                                    )
                                    Log.d(
                                        TAG,
                                        "categoryDesignID: ${uploadedImages.categoryDesignID}"
                                    );
                                    intent.putExtra(
                                        "categoryDesignID",
                                        uploadedImages.categoryDesignID
                                    )

                                    startActivity(intent)

                                }
                        }
                    }
                }
        }   

CategoryDe​​tailRecyclerViewActivity.kt

class CategoryDetailRecyclerViewActivity : AppCompatActivity() {

    val TAG = CategoryDetailRecyclerViewActivity::class.java.simpleName

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_category_detail_recycler_view)

        var intent = Intent()
        Log.d(TAG, "Intent:$intent ");
        var categoryDesignID = intent.getStringExtra("categoryDesignID")
        Log.d(TAG, "categoryDesignID: $categoryDesignID");

我的清单:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".ui.categoryDetailRecyclerView.CategoryDetailRecyclerViewActivity"></activity>
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我只想问为什么StartActivity(intent)失败?然后显示logcat:D / AddPhotosFragment:categoryDe​​signID:ClothingDesign D / EGL_emulation:eglMakeCurrent:0x7ea0c3349a00:ver 2 0(tinfo ...

android kotlin android-intent google-cloud-firestore firebase-storage
2个回答
3
投票

我不确定why StartActivity(intent) failed的意思,但是根据您的Logcat,它会打印出我希望从代码中得到的内容。


0
投票

此问题已解决。

© www.soinside.com 2019 - 2024. All rights reserved.