0

I created a android app, which has webview to load pages.

In my app, home page is EditText and Button, if user enters a URL in textbox then enters button, webview will loads the webpage. This works fine.

If user clicks URL in WhatsApp, mobile has options to open that URL in browsers.

I added the following code in my manifest file, to list my app along with browsers to open URLs

        <intent-filter>
            <action android:name="redacted.MainActivity" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>          

Now, my app name is also available as option to open the URLs. When I select my app to open the URL, it doesn't paste the url in edit text.

What I need to add more.

1 Answers1

0

In your main activity you need to describe how will onCreate behave when application is opened from an intent.

Reference link:- Link

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    // Get the intent that started this activity
    Intent intent = getIntent();
    Uri data = intent.getData();

    // Figure out what to do based on the intent type
    if (intent.getType().indexOf("image/") != -1) {
        // Handle intents with image data ...
    } else if (intent.getType().equals("text/plain")) {
        // Handle intents with text ...
    }
}
Ankesh kumar Jaisansaria
  • 1,563
  • 4
  • 26
  • 44