Setting my app as a sharing target (Xamarin) - android

I'm looking for a way to enable my users to send images to my app via sharing (On android).
My main goal right now is to get my app on the "share to" tab when pressing the share button in the gallery, and storing the shared picture(or a link to the picture).

To have your project in share list you need to manipulate your menifest file
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MyActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
</application>
& for more information on this you can visit this & this
In those links you might get things in more precise way.
Good luck.

I faced the same problem
After some effort, I found this solution
Remove this from the manifest file
<activity android:name=".MyActivity" >
.....
</activity>
And replace it with this code in the activity you want to run directly
[IntentFilter(new[] { "android.intent.action.SEND" }, Categories = new[] { Intent.CategoryDefault }, DataMimeTypes = new[] { "text/plain" })]
my best wishes

I have found my answer using a android studio instead of xamarin, as it was giving me a lot of problems.
If you have the same problem yourself, you should follow Arvindraja answer, please do not that his answer will only make your app appear in the share menu but the data you will share to it will not be saved anywhere, for that you will need additional code.

Related

App linking not working. How to open app from web browser?

I've followed the steps in the android documentation Here to implement linking in my application. I dont really need any fancy parameter passing, all I want is when the user clicks a link on the browser that my app opens. All I did was modify my AndroidManifest. Here is the relevant part
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="u2player" android:host="open.my.app" />
</intent-filter>
</activity>
I am using react-native-navigation and trying to browse from either the chrome browser or the native browser to any of u2player:// u2player://open.my.app u2player://open.my.app/ doesn't work. I have also binded the url event from the Linking module but nothing works. I restarted, uninstalled, etc.
Help appreciated
Try using branch. It solves most of the problem that you are facing and it also has a very clean documentation. Please go through and let me know if you have any issues

Why is my app not showing in the grid of icons (not the launcher) after installation

I recently started testing my react-native android application and noticed that it doesn't create an app icon on installation. When I debug - it seems to install and run fine, but when I look for it in the app icon to launch - it does not show up. Looking at the list of installed apps, it's there. How can I debug this? Do I need to change the launch mode from singleTop to something else? I tried changing it to singleInstance and it still had the same issue. If I remove some of the intent filters it seems to work - so maybe I messed up the branch.io installation instructions? Do I need to create a seperate intent filter xml node for the other intents? https://dev.branch.io/getting-started/sdk-integration-guide/guide/react/#android-configure-manifest
AndroidManifest.xml
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<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" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.EVENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Update
Splitting up the intent-filters seems to have fixed it - but a bit unclear if that is the correct thing to do. In the branch.io instructions - did they mean for me to create a new intent-filter and not add to the existing main one?
<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" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
The launcher is typically specific software developed by the individual hardware manufacturers. On all of the devices i have, an app does not get installed on the homescreen when it is not installed from the play store, but it does show up in the list of apps. However, that behaviour will be specific to the launcher you are using i think.
You should not need to go to settings->apps though just to see it. Is that the problem you are having?
Perhaps a screenshot as well as a description of your test device (s) would make the question clearer.
Update....
Typically the startup activity has one intent filter with only MAIN and LAUNCHER. I would just try to remove the other things from that intent filter and see if that resolves the problem. Then one by one, add the rest of the things you have listed until you identify the problem child.
Looking at this again, I am not sure that you can define 2 actions in a single event filter. So it seems you need to remove VIEW.

Why is my main activity being called every time my app is opened, even if not fully closed?

Every time I open my app, I am being routed through my main activity, rather than returning to the last activity that was previously opened. This only started occurring once I started using branch.io for deep-linking functionality. Why might this be happening? I assume that it has something to do with my manifest.. I'll post a snippet:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:name="roof.android.Application"
android:theme="#style/AppThemeNoAnimation"
android:largeHeap="true"
>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_bpzpbF3KFoq5TlSQFp0TdnaauEf6iBuU" />
<activity
android:name="roof.android.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="https://roof.app.link/RwKeFhqi5v" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
There are several activities which follow this, but I suppose it is not necessary to post them.
Alex from Branch.io here: looks like you have a mistake when defining your URI scheme:
<data android:scheme="https://roof.app.link/RwKeFhqi5v" android:host="open" />
should look more like
<data android:scheme="myscheme" android:host="open" />
(more about this step in our docs here).
You definitely will need to fix that, but I'm not sure if it would be causing the issue you are seeing. Give it a try and if you're still having trouble, I'd suggest submitting a ticket to our Integrations team so they can take a closer look at the code.

App icon not visible when code is run

I have created an android app using android studio. When i run my code on the IDE, its runs as expected on the connected phone. The problem is, it does not leave behind an icon on my phone to use it next time. I will again have to run from android studio to use the app. This was fine initially, i don't realize what made the icon vanish. The app is also present in the settings.
When i go to
Settings->apps
i can very well find my app over there. It is not disabled. I tried uninstalling the app and trying again. It still doesn't give me the icon.
I cleared defaults, forced closed and tried everything possible. Nothing is helping me.
Please help.
My AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".TwitterLogin"
android:label="#string/title_activity_twitter_login" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<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.chillumapp.com"
android:pathPrefix="/chillum"
android:scheme="http" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".NextActivity"
android:label="#string/title_activity_next" >
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="b1fe9f0c7d80c3c24879d634b199f2d0e474b4ba" />
<activity
android:name=".WebViewActivity"
android:label="#string/title_activity_web_view" >
</activity>
</application>
</manifest>
You should specify a different for every intent that can launch your app. So one for the BROWSER category with your url data, and one for the LAUNCHER category.
From the App Manifest Guide.
Components advertise their capabilities — the kinds of intents they can respond to — through intent filters. Since the Android system must learn which intents a component can handle before it launches the component, intent filters are specified in the manifest as elements. A component may have any number of filters, each one describing a different capability.
Your code would become something like:
<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" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.chillumapp.com"
android:pathPrefix="/chillum"
android:scheme="http" />
</intent-filter>

Link to an android application from SMS/mail

I would like to know if we can have a link in a SMS that would be handle by my application. For example a link which would look like myapp://blabla. And by clicking on it myapp would be open with the link as an argument.
This question also refers to email, either from a file with a special extension or a link like in the SMS.
Thanks a lot for your help.
Edit 31/01
Actually, I did what Greg suggested it but it doesn't work. Such a link (myapp://blabla) is not clickable in a SMS/email...When I replace myapp with http as a scheme, it works (Android asks me wether it should open the link with myapp or the browser). But myapp://blabla isn't clickable with myapp as a scheme.
Here is my code:
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".myapp"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
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.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
<activity android:name=".SettingsActivity"></activity>
</application>
Yep you can with an intent filter.
Basically in your android Manifest, choose an activity that you want to be the one that handles the given url.
<activity android:name=".myactivies.MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>
Then inside your activity you can get the url by calling getData() on the intent.

Categories

Resources