Make a link in the Android browser call an intent receiver - android

I would like to make a link in Android browser to be able to call a receiver.
I read this post on how to make a link start my app and tries to do the same for my startup receiver receiver, but it didn't work.
Is it possible?
My receiver is configured as follows:
<receiver
android:name="com.wiziapp.wiziappweb.app.MyStartupIntentReceiver"
android:label="#string/search" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<data android:scheme="myapp" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</receiver>
The link I use to test it is:
Enable notification

I would like to make a link in Android browser to be able to call a receiver.
That is not possible.
My receiver is configured as follows:
ACTION_VIEW is used with startActivity(), not sendBroadcast(), so your second <intent-filter> is unlikely to ever be used.
The link I use to test it is
Links only call startActivity(), not sendBroadcast(). Your are welcome to have the link point to a Theme.NoDisplay activity that sends the broadcast and then calls finish() to go away.

Related

How to launch the app from SMS content (link)

i need to launch my app when click on link that is received by sms or email.I mean, the person who receives the SMS simply taps on the link provided, and that launches the application.
Which ever Activity you want to open, when Link is clicked
Need to be use IntentFilter in Menifest like this
<activity
android:name=".interacting.InteractWithApps"
android:parentActivityName=".index.IndexActivity">
<intent-filter>
<data
android:host="www.domain.com"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You also need to define link schema and host
You should follow as per this link

Android start service from link?

Is it possible to start Service from link. I try with code below but it is impossible to start.
Link:
"test to launch myapp <br /><br />"
Example:
<service android:name=".PrintService"
android:enabled="true">
<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="com.example.tohome" android:host="deeplink"/>
</intent-filter>
</service>
No, sorry. Browsers, to the extent they honor custom schemes, will only use them to start activities. You are welcome to have a Theme.Translucent.NoTitleBar activity, though, that starts the service and then calls finish(), all from onCreate().

Receive android internal intent Broadcast

What happens when we click the default message app in android.I mean does it broadcast an intent? Actually I am trying to make an app that will ask for a password in an new activity when user clicks on message icon and is redirected to list of messages only if password is correct.But my activity is not shown.Here is how I am trying to do it.Added a receiver in manifest.
<receiver android:name="Receiver">
<intent-filter android:priority="100">
<action android:name="android.intent.action.GET_CONTENT">
</action>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType = "vnd.android-dir/mms-sms" />
</intent-filter>
</receiver>
You are asking about "launching" an activity. Typically that is done with an intent created as such:
Intent launch = new Intent(Intent.ACTION_MAIN);
launch.setPackage("com.your.package.name");
startActivity(launch);
Because the package name is set, you cannot intercept this intent. It is not broadcast to any receiver.
If you write a launcher app, you could intercept such a launch request and launch a different app in front of it. But it would not really be possible to prevent users from side-stepping this by returning to the default Android launcher.
However, there are several other means of "launching" the "default" SMS app. For example, an app that requests an SMS be sent through the default SMS app will create an intent like this:
Intent launch = new Intent("android.intent.action.SENDTO");
There are several others as well. And your app can register an activity for these intent in the manifest like this:
<activity
android:name="com.your.package.name.MyMessageActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android-dir/mms-sms" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
In Android KitKat a user must actually set your app as the "Default SMS App" in order for it to be able to write to the SMS provider/database and also to receive the "SMS_DELIVER" intent. In all versions of Android, any app can register for the "SMS_RECEIVED" intent but in KitKat+ it cannot be aborted, like in earlier versions.
You may notice that one filter specified above is similar to yours - using mimeType "vnd.android-dir/mms-sms" as a "DEFAULT" action. This places your app as one option for the user to "Complete Action Using" when, for example, they select a contact they want to message.
If you do all of this, then your activity can require a password in order to "view" messages. However, you should be aware that unless you are using a separate data store for the messages, all SMS can be read through the MMS-SMS provider (assuming the app has requested permission to do so).
What you are trying to achieve is not possible, please see this:
https://stackoverflow.com/a/21469133/2452039
You cannot prevent native applications from opening with an outside app. The only thing you could do would be to intercept incoming messages, preventing them from reaching the SMS app inbox, and store them in your application, and there you could prevent them from opening. I must warn you that since API level 19 that is no longer possible...

How can I add my application to the android default Dialer selection?

My Question is how can I add my application to the android default Dialer selection, to be more specific without using the android.intent.action.CALL_PRIVILEGED?
Now I am using this code below, this works fine:
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
HOWEVER Google recently posted: http://productforums.google.com/forum/#!topic/mobile/wXqnbynsL8Y
And mailed this to the programmes who does use the intent android.intent.action.CALL_PRIVILEGED:
Issue:
Users of your application may not be able to make emergency
phone calls through the system phone dialer if they've elected to have
your application route calls. As noted in the documentation,
applications that listen for the CALL_PRIVILEGED Intent action will
intercept emergency service calls from the system, but may not be able
to route them properly. Please note that CALL_PRIVILEGED is a
restricted API, not intended for use within third party applications
that cannot route emergency calls properly.
Solution:
• Remove CALL_PRIVILEGED from Intent filters in Java code and AndroidManifest.xml.
• Update your Google Play listing
description to include a statement that using your app as a default
dialer may interfere with dialing 911 emergency services.
The easiest solution my be deleting but then the application would use functionality. But is there another way to add the application to the default Dialer selection? but then without the CALL_PRIVILEGED intent?
Thanks in advance
Just an example of the default Dialer selection
Edit:
My other intents that I use:
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
More important is that privileged call action is needed in intent filter with data as "tel" for uri.
Also below permission tag is need to allow phone call.
Missing in your code in category Launcher.
<uses-permission android:name="android.permission.CALL_PHONE" />
You don't need to intercept CALL_PRIVILEGED to make a dialer. There are 3 intents of interest:
ACTION_DIAL: invokes the dialer. You should intercept this.
CALL: places a call. I suppose you need to intercept this if you are routing the call via VoIP, else just pass it on to the system.
CALL_PRIVILEGED: places an Emergency call (911 in US etc). You don't need to intercept this, since these calls are routed specially, even without a SIM card, and without charging the user.
For what it's worth, I got the same email from Google. My app doesn't even use CALL or CALL_PRIVILEGED intents. There was however, a check in the code that the passed intent was not this action (just for the sake of completeness). So, I think they just scan the data section of the apk to see if this string is used anywhere.
Edit try this, it works for my app:
<activity android:name=".ActivityName"
android:label="#string/activity_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DIAL" />
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity-alias android:targetActivity="fully.qualified.ActivityName"
android:name="fully.qualified.ActivityName_HTC_hack"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity-alias>
Try "android.intent.action.DIAL". The user has to start the call manually, but i think it's the best solution.
Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number.
ref: developer page

Android: proper intent-filter to indicate my application can open a filetype?

I am trying to configure my manifest file to indicate my application can open PDF files. The below configuration works, but it gives some funny behavior with the emulator:
When the "view" action is present, my application is not started on install (when I run from Eclipse, the application gets installed on the emulator, but it does not start automatically).
When application/pdf is present, after running from eclipse the application doesn't show up in my emulator's application menu.
(I don't see either of these issues if my only intents are "main" and "launcher")
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
EDIT: Okay, I was a little confused about intents. The solution to my above issues is to have 2 different intent-filters, as shown below.
However, I do have a second question. Android successfully launches my app for PDF files, but when it launches onCreate(bundle) is called and not startActivity(Intent). How should I get the intent data?
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
In your Activity, you can use getIntent() to get the intent used to start it.
startIntent() is not a callback. Its a method for you to call in order to launch another intent.
When your Activity is launched, you will get your onStart() (and onCreate, just before that), called, and from there you call getIntent() to re

Categories

Resources