Android start service from link? - android

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().

Related

Don't destroy activity

my app/activity (starts a tracking) can be started from another app. In my case the app is called from browser. I added an intent filter for incoming links.
<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="destination"
android:scheme="mwde" />
</intent-filter>
This works fine. My problem is, that when user start the activity again, the onDestroyed function is called, but I don't want that in this case. Is there any way to prevent this?
Try to use this flag in the app manifest
https://developer.android.com/guide/topics/manifest/activity-element#lmode

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

How to call an app mobile via web view?

is there a solution to call a mobile app via a link in a web page(my web page is a web view in a mobile app). For example, I want to call facebook app when tap on a link.
You need to create an <intent-filter>. See Launch custom android application from android browser.
For the simplest case, you need to add something like this to your AndroidManifest.xml:
<intent-filter>
<data android:scheme="http" android:host="your-url-.com"/>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
You have to add an Intent filter in Manifest file like this -
<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="www.tamrakar.in"
android:path="/test"
android:scheme="http" />
</intent-filter>
Hope this helps.

Make a link in the Android browser call an intent receiver

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.

Making my Service accessible using intent-filter

I want my service to be accessible as one of the default options of the Share page when the user long-touches the web-link (standard android feature). This is what I wrote in the manifest file :
<service android:name=".ShareLink"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</service>
But it is still not being displayed. What am I doing wrong? P.S. When I do the same thing with the Activity - it works fine.
This is not possible, You will have to write a Dummy Activity to do this.
This is because, ResolverActivity that shows the names or selects the appropriate component to launch gets the list by querying Only Activities that match intent with API PackageManager.queryIntentActivities
This should do it:
<intent-filter
android:label="Open Using My Service">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>

Categories

Resources