简体   繁体   中英

Receive URL intent in Splash Screen and load the URL in WebView

I'm having a slightly different purpose, but, I think I'm putting it wrong as no one from multiple forums is able to answer it. The original question is here: Pass URL data from AppLink to WebView

Basically, suppose I'm creating a web browser app with a splash screen and I want to accept the URL intents from other apps, receive them in my splash screen, pass them on to my WebView activity and load it there, how can I do that?

For example, if a user has my app installed, and he/she taps https://www.google.com/ as a link in some app, how can I load the URL in my app after showing my splash screen? I think, the intent receiver will be in the splash screen activity, and the WebView is in another activity. So, basically, I want to receive the URL in my splash screen activity and then, pass it on to my WebView. How to achieve this?

I think what youre trying to do is to recieve data from other apps

That way, you can recieve data in a Splash Screen Activity and then show it in a Web View Activity

You can do this through putExtra method.

You can use intents, which are messages sent between activities. In an intent you can put all sort of data, String, int, etc.

In your case, in Splash Screen(say SplashActivity), before going to next activity(say MainActivity), you need to store a String message this way :

Intent intent = new Intent(SplashActivity.this, MainActivity.class);
intent.putExtra("message", message);
startActivity(intent);

In MainActivity, in onCreate(), you can get the String message by retrieving a Bundle (which contains all the messages sent by the calling activity) and call getString() on it :

Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");

Then you can use message variable as url.:

Hope this helps !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM