Block Android Activity launch

Question: Question:

I want to filter whether to start Activity.
It is not good to finish with onCreate, and I want to prevent the activity from starting before that.

Instead of ending in an instant, I want to filter the start of the activity itself in advance and block it according to the situation.

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

What I really want to do is to disable a specific scheme, so I want to intercept it with an intent filter, but I don't want to start Activity for a moment anyway.
This is because the stack is swapped and the current activity is behind.

So I thought I would receive the scheme with the intent filter in Service,
The scheme seems to receive only Activity.

So, in the manifest, write that you will receive the scheme in Activity,
In fact, I wanted to stop the activity before it was called.

I'm sorry I'm messed up …

Postscript I don't need it anymore, but the reason why I want to achieve this is
Do you know the UFJ app?
It has been improved now, but it has been annoying for a long time, so I decided to make an app that keeps the user in a good mood from the UFJ app.

What the UFJ app was doing-When the developer mode is ON or USB debugging is ON Anyway, if you connect the USB, the browser will be displayed and a warning will be displayed.
(Anyway, it's annoying because the browser is displayed without permission every time you connect the USB.)
I wanted to block this behavior.

Therefore, in order to override or absorb the browser startup intent issued by UFJ,
Your activity will steal that URI.
However, due to the mechanism, my activity will always start this time.
Even if I end my activity immediately, the app that the user was running will move to the background and return to home.
So even if it could be stopped, the problem that the user's application was interrupted could not be solved.

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

Answer: Answer:

I want to disable a specific scheme

I'm not sure about the use case, but for example, to create an app that responds to the "call" intent, I think that NEW_OUTGOING_CALL is set in the activity's intent-filter.

Now when the user makes a "call" action, your app will appear in the choices, but I don't think it's good for usability to be unresponsive to that choice.

If you can disclose the reason why you want to do so, I think it is easier to gather advice if you write it.

Scroll to Top