Prevent Android Activity from Starting

Asked 1 years ago, Updated 1 years ago, 69 views

I want to filter whether I want to start Activity or not.
I can't finish with onCreate, and I want to prevent activities from starting before that.

Instead of finishing in an instant, you can pre-filter the activity itself to begin with
I'd like to block it depending on the situation.

I wondered if I could do it with an application, but I couldn't.
Is there any way?

Actually, I want to disable a particular scheme, so I want to intercept it with an int filter, but I don't want to start Activity even for a second.
This is because the stack changes and the current activity is behind it.

So I wanted to receive the scheme from Service with int filter, but
The scheme seems to receive only Activity.

Therefore, in the manifesto, I wrote to receive the scheme in Activity, and
Actually, I wanted to stop the activity before it was called.

I'm sorry for the mess...

Additional
I don't need it anymore, but the reason I want this to happen is because
Do you know the UFJ app?
It's improved now, but since you've been doing the following things for a long time, I thought I'd make an app to keep users in good mood from the UFJ app.

What UFJ app did
·When the developer mode is ON or USB debugging is ON, connect USB anyway
Show a browser to warn you.
(Anytime I connect USB, I display my browser without permission, so it's annoying)
I wanted to block this behavior.

Therefore, in order to override or absorb browser-initiated intents published by UFJ,
Your activity intercepts the URI.
However, because of the structure, this time my activity will always start.
Even if you close your activity immediately, the application that the user was running moves to the background and returns to the home.
So even if I could block it, I couldn't solve the problem that the user's app was interrupted.

I wish the service could absorb the intents, but this kind of intents could only absorb activity.

android android-activity

2022-09-30 19:33

2 Answers

You want to disable a particular scheme

I'm not sure about the use case, but I think NEW_OUTGOING_CALL should be installed in the Activity int-filter to create an application that responds to "call" intents.

Now, when a user takes a "call" action, your app appears in the options, but I don't think it's good for usability to choose it.

If you can disclose the reason why you really want to do so, I think it would be easier to get advice if you write it down.


2022-09-30 19:33

<activity
    android:name = ".TranslucentActivity"
    android: launchMode="singleInstance"
    android:theme="@android:style/Theme.Translucent">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>

        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>

        <data
            android: host="test.com"
            android: scheme="http"/>
    </intent-filter>
</activity>

Set the Activity to transparent on AndroidManifest as shown above, and then
If you use onCreate to Activity#finish(), you will be able to do it as if it were not started

In this case, the user must specify the specified URL as the default setting in the blocker application.


2022-09-30 19:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.