Java – why is an exception thrown when an unused activity is uploaded to the play store?

I have an application that was recently uploaded to the play store and enabled crashlytics. In this application, there is an activity called startquizactivity, which was created during development but is not currently used. The activity is still declared in the list, but there is no intention to call it in the application

I received a crash report showing a stack trace, prompting the device to attempt to start this activity, resulting in an illegalargumentexception, indicating that the required object was not passed through the intent:

StartQuizActivity.java

@Override protected void onCreate(Bundle savedInstanceState) {
        aminoAcid = getIntent().getExtras().getParcelable(AMINO_ACID);
        super.onCreate(savedInstanceState);

        if (aminoAcid != null) {
             // do things
        } else {
            throw new IllegalArgumentException("No extras supplied to startQuizActivity!");
        }

Since startquizactivity cannot be started using the UI of the application, why can the device start this activity? I noticed that the device is a nexus running API 21 and has encountered similar crashes in other activities in the application. Even if I tried monkeyrunner, I couldn't reproduce the crash on any device

Is this some form of automated testing by Google or users with specific device settings? Any ideas would be appreciated

AndroidManifest.xml

<activity
    android:name=".activities.StartQuizActivity"
    android:label="@string/activity_title_prepare_for_quiz" />

resolvent:

When you add an activity to the list using Android: exported = "true" (the default setting of the activity), the activity becomes part of a public API that can be called by any application

Understandably, for other applications, there is little reason to explicitly start random activities from another application for no reason. It is very rare, but applications like Tasker do allow end users to do this

You can

>Remove the activity from the list - obviously, this completely removes any ability to start the activity > Add Android: exported = "false" - this ensures that other applications cannot start the activity > if no other services are provided, please call finish() to stop the activity immediately

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>