My activity is not shown in the chooser list when requesting ACTION_VIEW. What is wrong in my code? In the emulator -> Settings -> Apps -> Default apps -> Browser app, I see my app correctly (Chrome is default). If I set my activity to be the default browser, for sure it is called without problem. A chooser shouldn't show it in the list even if it is not the default app?
Activity that simulates a Browser:
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"/>
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
Activity in another app that requests an ACTION_VIEW:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
Intent intentChooser = Intent.createChooser(intent,"Choose an app");
startActivity(intentChooser);
I tried with other actions, the same problem is encountered as with ACTION_VIEW.
Related
If there's a WhatsApp chat which has location shared, when clicked it shows a chooser intent with some set of applications. I want to write an intent filter so that my application will also be listed there.
You can do it by supporting implicit intent to your Activity.
Define intent-filter to Activity to which you want to open after clicking to your Application from options.
<activity android:name=".BrowserActivitiy"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
<data android:scheme="geo"/>
</intent-filter>
</activity>
To know more about Intents and Intent filters go to official website.
https://developer.android.com/guide/components/intents-filters
Add this to your Manifest file (Particular activity):
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="geo" />
</intent-filter>
I am trying read barcod and then get URL from this barcod and then trying to open this URL. it show this page which is open with app or continue with browser . even if select open with app . it will ask me this page next time. how can directly open this url with Autocad a360 app.
this is my code:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(StringURL));
startActivity(intent);
Add this code to manifest.
<activity
android:theme="#style/AppTheme.Launcher"
android:name=".features.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="YOURSITE.com"
android:scheme="http" />
</intent-filter>
</activity>
App will launch when you try to open http://YOURSITE.com
Deep link was correct answer
Launch app when click on url if app installed on device. if app not installed on device, open playstore.
<activity android:name=".ui.NewsCardActivity">
<intent-filter>
<data android:scheme="app" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
You have to deep link your app, add following lines in activity (Manifiest.xml) which you want to launch
<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="screen" android:scheme="appname"/>
</intent-filter>
in browser when ever you click appname://screen your app activity will be launched,
replace appname and screen as per your requirement
Note if you type this url in browser it will search in google ,for this to work you have to write link in html page
Some text
If not working the add android:exported="true" in activity
<activity
android:name=".activity.MainActivity"
android:exported="true">
For analytics, I am gathering data on what URL/URI causes my app to be launched.
When I inspect the intent and the data to determine the URI that started it, using:
getIntent().getData()
the URI is often of the format "custom://123456789" (many different large numbers show up)
I would like to understand what causes it to be launched with that Uri format, to know if I can safely filter those cases out from stats.
As requested: Here is the activity entry in manifest with intent filter to catch starting from the Launcher, or from clicking on a URL from my domain.
<activity
android:name=".ui.activity.MainActivity"
android:clearTaskOnLaunch="true"
android:configChanges="locale|orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Capture the opening of the app via a link to app.tuenti.com -->
<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:scheme="http" android:host="mydomain.com"/>
<data android:scheme="https" android:host="mydomain.com"/>
</intent-filter>
</activity>
I've read a tutorial on how to launch an app from a link on the browser. I've created an activity 'TestLaunch'.
<activity
android:name=".TestMe"
android:label="Test">
<intent-filter>
<data android:scheme="testme.com" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
Then I connected my android phone and clicked 'debug' on Eclipse. The app launched as usual. I openned the browser and typed 'testme.com'. The activity was not started as expected. Is this because the app is not fully installed on the phone or because I am understanding wrongly how the intent filter works?
try this:
<activity
android:name=".TestMe"
android:label="Test">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.testme.com" android:scheme="http"></data>
</intent-filter>
</activity>