sulphuric Acid
sulphuric Acid

Reputation: 33

How to open specific activity on clicking on link?

I am working on an android app in that i have added sharing whatsapp sharing feature,I have done it successfully,Now i want to open a specific activity of my android application when user click on link i have shared.I have searched few links but no luck,I hope somebuddy will help me in this.

Added manifest

  <activity
            android:name=".ProductDescriptionActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.NoActionBar">

            <intent-filter>
                <action android:name="com.abc.allaboutcity.MESSAGE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>


            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http"
                    android:host="http://allaboutcity.in"
                    android:pathPrefix="/allaboutcity" />
            </intent-filter>

            <intent-filter >
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "example://gizmos” -->
                <data android:scheme="allaboutcity"
                    android:host="allaboutcity" />
            </intent-filter>
        </activity>

Upvotes: 1

Views: 4526

Answers (2)

Vivek Akkaldevi
Vivek Akkaldevi

Reputation: 9

use this code In Your WebView Activity

      Intent intent = getIntent();
      String action = intent.getAction();
      Uri data = intent.getData();

      Webview webView = (WebView) findViewById(R.id.webview_id);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.loadUrl(""+ data);

next, use this code in AndroidManifest.xml, its for all link (Https / Http):

        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
             <data android:scheme="https"/>
            <data android:scheme="http"
                android:host="http://allaboutcity.in"
                android:pathPrefix="/allaboutcity" />
            <data android:host="www.host.com" android:pathPattern="/movie/0.*/" android:scheme="http"/>
        </intent-filter>

Upvotes: 0

Ergin Ersoy
Ergin Ersoy

Reputation: 889

You should add intent filter in your manifest file to activity that you want to open

<activity
    android:name="Your Activity"
    android:label="Your Activity Title"
    android:theme="Your Style">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="your url"
            android:path="/your path"
            android:scheme="http" />
    </intent-filter>
</activity>

Upvotes: 3

Related Questions