Add my Android app to the "send via" menu - java

I use the OSMand Navi app. In there I want to click on a point a hit the Share button. Then there is a list of apps I can send the coordinates to.
I want my app being in that list. I read about it and added an <intent-filter> to my AndroidManifest.xml.
<application
<activity
android:name=".MyMainActivity"
android:label="My App" >
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
But my app is still not on the list. I even tried to reinstall it and restarted my phone.

"Share" is usually implemented via ACTION_SEND, not ACTION_GET_CONTENT.

Related

My NFC Scan application starts only if NFC Type 2

I've made an NFC application who can reads NFC tag. It works well. (With all types)
But since yesterday i'm trying to start automatically my app once a NFC tag is maintained against my device.
So i've updated my Manifest :
<activity android:name=".MainActivity" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/nfc_tech_filter" />
</activity>
Then, here is my nfc_tech_filter.xml
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.NfcB</tech>
<tech>android.nfc.tech.NfcF</tech>
<tech>android.nfc.tech.NfcV</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.MifareClassic</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
</resources>
And surprise, it works only when I hold a NFC Type 2 against my device.
I've try with my appartement key (Mifare Classic) and my bank card (IsoDep), and it doesn't launch my app...
I specify that it works when my app is already started.
Any idea?
EDIT :
This is my Manifest right now :
<activity android:name=".MainActivity" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="#xml/nfc_tech_filter" />
</activity>
Now, when I pass my bank card, it opens the application but doesn't display any result.
Parcelable[] rawMessages =
intent.getParcelableArrayExtra(NfcAdapter.EXTRA_TAG);
rawMessages variable is NULL after that. Same if I put NfcAdapter.EXTRA_NDEF_MESSAGES
ACTION_TAG_DISCOVERED:
This intent is started if no activities handle the ACTION_NDEF_DISCOVERED or ACTION_TECH_DISCOVERED intents.
https://developer.android.com/guide/topics/connectivity/nfc/nfc
You get this Intent when no others has captured it, so there is something wrong in your setup.
You can capture it explicitly like:
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>

How can i make two activities to one file?

I made two activities in Android Studio. One of them is an empty activity the other is a Basic activity. My Problem now is that if I run the app my Smartphone Shows me two files. How can I make this into one file?
[]
It seems both of your activities have the android.intent.category.LAUNCHER
<activity
android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Opening Android application from website not working

I want to implement such functionality in my simple Android app: when user visits a certain link (www.example.org let's say) in the web browser - Android OS should open my Android application if it is installed.
I tried to play with intent-filters like this:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<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="example.org"
android:pathPattern="/.*"
android:scheme="http" />
<data
android:host="www.example.org"
android:pathPattern="/.*"
android:scheme="http"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But it's not working at all in google chrome mobile browser. In firefox, when I visit that link I get such Android icon on the right side of the search bar:
When I press that icon - my app opens. But still it is not what exactly I want to achieve.
Any idea why my code above doesn't work? I tried many variations of intent-filter declarations which I found on internet but nothing seem to work. I have nexus 5 device with Android 6 installed.
I have found a solution to my problem. Whole internet is full of old examples.
Since chrome version 25, google made slight changes in app deep linking functionality. More info: https://developer.chrome.com/multidevice/android/intents
So my working code looks like this:
Intent filter in Android side:
<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="launcher"
android:path="/"
android:scheme="test" />
</intent-filter>
Web page html:
Launch app
Try it like this, removing the path pattern:
<intent-filter>
<data android:scheme="http" android:host="twitter.com"/>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
More info:
Launch custom android application from android browser
<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="example.org"
android:scheme="http" />
</intent-filter>

Android intent data not redirecting mobile phone to application

I am at my wits end with this. I am trying to have the user click on a link in a text message and the phone direct them to my app. However it autommatically goes to browser. Please help!
My android manifest looks like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustResize">
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="www.myapp.com"/>
</intent-filter>
</activity>
Looking at every forum I am doing this correctly yet it still does not work. Please help!
You need to use a broadcast receiver, it is the receiver that has to be configured on the intents you're listening on, when such an intent takes place your receiver should bring to foreground an activity or do whatever else you need to.
Something like this may help you achieve what your trying to do :
https://stackoverflow.com/a/525086/1542720

Open Android app from browser

I am trying to open an Android app from a browser. I have read several StackOverflow threads describing a solution to the problem and this is what I have so far:
AndroidManifest.xml
<activity
android:name="com.webviewtestapp.MainActivity"
android:label="#string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="Testapp" android:host="launch"/>
</intent-filter>
</activity>
And this is the html <a href="Testapp://launch"> open testapp </a
I am using the Firefox browser in Chrome and clicking the link gives a message: Couldn't find an application to open this link
How do I fix this ?
Change:
<action android:name="android.intent.action.MAIN" />
to:
<action android:name="android.intent.action.VIEW" />

Categories