Getting url with Intent Android

android open google maps intent with directions
android intent url scheme
open android app from url with parameters
how to pass url in intent in android
android navigation intent
how to use intent in android studio
how to receive intent in android
android send intent to specific app

Im trying to get the URL that was clicked in order to open the app. Im just having trouble finding where I can get that information. I have a manifest which opens app when clicked. The link would be "http://host.com/file.html?param=1&param2=2" which Im trying to give to the app to handle.

 <intent-filter>
           <data android:scheme="http"
                android:host="host.com" 
                android:pathPrefix="/file.html" />
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.BROWSABLE" />
          <category android:name="android.intent.category.DEFAULT" />
 </intent-filter>

EDIT

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

        Intent intent = getIntent();
        Uri uri = intent.getData();
        try {
            url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

You should be able to get the intent data in your activity with the following:

Uri uri = this.getIntent().getData();
URL url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());

Getting url with Intent Android, Step 1 − Create a new project in Android Studio, go to File ⇒ N android:​layout_height="wrap_content" android:text="Get URL from Intent"  This example demonstrates how do I send an Intent to browser to open specific URL in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

Uri uri = this.getIntent().getData();
    try
    {
        URL url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
    }
    catch (MalformedURLException e)
    {

    }      

You will have to Surround with try/catch.

Sending an Intent to browser to open specific URL in Android?, resolve to the correct app activity. You can run the adb command against a device or an emulator. String user_name = intent.getStringExtra("USER_NAME"); //if you have used any other type of data, you should use the //particular getExtra method to extract the data from Intet Integer user_id = intent.getIntExtra("USER_ID"); float user_rating = intent.getFloatExtra("USER_RATING");

Basically once you obtain your Uri (that is, getIntent().getData()), you can read your complete url as uri.toString(). Assuming your android:host is valid and set, you can also get actual query data by calling uri.getEncodedQuery().

Here is more details from working sample, if needed:

  1. This is my manifest setup:
            <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="boo.acme.com"
                    android:scheme="http" />
            </intent-filter>
  1. This is how I read Uri:
Uri uri = this.getIntent().getData();
  1. Assuming user clicked url "http://boo.acme.com/?ll=43.455095,44.177416", uri.toString() produces "http://boo.acme.com/?ll=43.455095,44.177416" and uri.getEncodedQuery() produces "ll=43.455095,44.177416".

Hope that helps!

Create Deep Links to App Content, If that is the case you will get this exception: android.content.​ActivityNotFoundException : No Activity found to handle Intent. The URL must always start with  An Intent is a messaging object you can use to request an action from another app component . Although intents facilitate communication between components in several ways, there are three fundamental use cases: An Activity represents a single screen in…

Android Intent Example, An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a  Setup a proper <intent-filter> in your Manifest as an entry point. Consider setting android:launchMode="singleTask" for the target Activity to avoid running multiple copies of your Activity on the same time. Handle the Intent. Match the deeplink with predefined regular expressions to navigate the user to the proper page/content.

Intent / Open a URL in a browser / Essential Android, If that is the case you will get this exception: android.content.​ActivityNotFoundException : No Activity found to handle Intent. The URL must always start with  Android Intent Tutorial. Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose. So, it can be described as the

Common Intents, A little known feature in Android lets you launch apps directly from a web page via an Android Intent. One scenario is launching an app when the user lands on a  If you want start activity, you write code like this. Intent intent = new Intent(this,AAA.class); startActivity(intent); And If you want launch url page, you will pass Uri with Intent.ACTION_VIEW

Comments
  • I added my current OnCreate method up top. still isn't seeming to work though.
  • My onCreate Method seems to be not being called, from my understanding it will be called when the system calls onCreate and it will redirect to the onCreate I made by overriding it.