my activity not being called with action_view - android

i have create an activity in an application com.example.one which calls another activity in application com.example.two.
In the activity two manifest i have declared the following intent-filter
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
However on calling this activity with action - Intent.ACTION_VIEW or even with android.intent.action.VIEW directly invokes the browser rather than a Intent chooser that i have put.
Intent ii=new Intent(Intent.ACTION_VIEW);
ii.setData(Uri.parse("http://www.google.com"));
startActivity(Intent.createChooser(ii,"done"));
kindly update why i am not getting the intent chooser for browser and my activity.
thanks

Probably you need to include another browsable category with intent filter.
<category android:name="android.intent.category.BROWSABLE" />

Clear the browser defaults settings, than try to invoke your
method, it should ask for the action to choose the available apps,
with this time only and always, here you go with it.
To clear go to the settings -> Apps -> browsers [Chrome, Firefox or any other if installed]
than to each browser press button 'Clear defaults'.

Related

How to launch our application when user click on a weblink in system application like hangouts?

I want to launch my application if user click on a web link in another application and if user wants to open that link with my application.I used following 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" />
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:host="www.google.com"/>
</intent-filter>
But if user click on that link in another application that application is opening activity of my application in that application itself but i want to launch that activity in my application.
For example
suppose there is a link in hangouts like www.google.com if user click on that link it will show some apps to open in that if user select my app then it has to launch my application but it is launching my application activity in hangouts app itself without launching my app.
Please help me to solve this issue,Thanks in advance.
Try this:
Intent i=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.stackoverflow.com"));
startActivity(i);
Try this on event onClick:
Intent it = new Intent(Intent.ACTION_VIEW);
it.setData(Uri.parse("http://www.google.com.br"));
startActivity(it);

Open Activity from url is not working android

Hello friends i want to open my application when particular type of url is being called in browser (Predefined format)
following is rout on server
Redirect::to('intent://com.customlymade.activit/#Intent;scheme=customlymade;package=com.customlymade.activity;end');
and following is the intent filter i am using in my manifest file
<intent-filter>
<data
android:host="com.customlymade.activity"
android:scheme="customlymade" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
But Nothing is working Please help.
I guess, that the redirect is executed automatically. Chrome in android has a security feature, that starting an activity can only be done after a user action (like clicking on a link). See chapter "See also" at https://developer.chrome.com/multidevice/android/intents
And Chrome doesn’t launch an external app for a given Intent URI in the following cases.
When the Intent URI is redirected from a typed in URL.
When the Intent URI is initiated without user gesture.

Android - open url in my app when my app is already opened

I'm trying to open a specific url with my app instead of browser. I have it working correctly except if my app is already open, the url doesn't open to the page specified.
My manifest file is as follows:
<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="myapp"/>
<data android:scheme="http"/>
</intent-filter>
And I'm getting the intent data as:
Intent intent = getIntent();
Uri data = intent.getData();
But getIntent() returns the intent that started my activity, what if my url click didn't start my activity and the activity had already been created, how do I get the intent for whatever is resuming the app (so my specific path link). Is that even possible???
I am targeting Android 4.2.2
how do I get the intent for whatever is resuming the app (so my specific path link)
Override onNewIntent() and use the Intent passed into it.

Reading gmail attachment in my app

I am trying to read (first time - new to me) a gmail attachment (.gcsb extension) in my app. The intent filter looks like this:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:pathPattern="*.gcsb"></data>
<data android:mimeType="application/*"></data>
</intent-filter>
and that appears to get the 'download' and 'preview' buttons to appear next to the attachment in gmail (without that filter, the buttons do not appear).
In the activity (onCreate() / onRestart()) I do:
....
Intent intent = getIntent();
if (!Intent.ACTION_VIEW.equals(intent.getAction())) {
// Deal with the file from gmail here
}
....
to check if it is gmail that has caused this to start the activity or not.
However intent.getAction() always resolves to android.intent.action.MAIN, so it never does anything. There is another intent filter in the activity:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
being for the app launch, but I don't understand why I never see the android.intent.action.VIEW from gmail?
The answer appears to be that the activity was set to be 'single instance' for various reasons. This means that whilst it is brought to the foreground again, it comes back with the intent it was originally started with, not the one created by gmail.
Removing the 'single instance' attribute allowed the correct intent to be used.

Make my activity one of the mail apps shown in the intent chooser

When clicking an email address from a browser or contacts app...
Is there any way for my app to show a mail client in the intent list?
As you can see from the Mail application's source, having your application catch the intent is as simple as adding the intent-filter to your AndroidManifest.xml inside your mail composition activity definition.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
You can see that the <data> tag specifies to handle mailto: links. The BROWSABLE category means it can be launched from the browser.
K-9 Mail is similar, except using the SENDTO action only with the DEFAULT category, and the VIEW action only with the BROWSABLE category.
You need to use an Intent Filter. Check out http://developer.android.com/guide/topics/intents/intents-filters.html for more information. You usually declare these in your manifest file. The intent I believe you're looking for is Intent.ACTION_SEND.

Categories

Resources