I want to open files with customized extensions in my app. It can come from email, downloads, Bluetooth etc. Whenever user taps on those files my application should open and perform some tasks. I need a reference/help for xamarin platform. I am literally new in this.
My android menifest
<activity android:name=".StartFileActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.IE3" />
<data android:mimeType="application/*" android:scheme="content" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:host="com.ppp.androidintentfile" />
<data android:host="*" />
<data android:pathPattern=".*\\.IE3" />
<data android:pathPattern=".*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:mimeType="*/*" android:scheme="content" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" android:host="com.ppp.androidintentfile" />
<data android:host="*" />
<data android:pathPattern=".*\\.IE3" />
<data android:pathPattern=".*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:mimeType="*/*" android:scheme="content" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" android:host="com.ppp.androidintentfile" />
<data android:host="*" />
<data android:pathPattern=".*\\.IE3" />
<data android:pathPattern=".*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.IE3" />
<data android:mimeType="*/*" android:scheme="content" />
</intent-filter>
</activity>
Activity Code
namespace AndroidIntentFile
{
[Activity (Label = "StartFileActivity")]
[IntentFilter(new[]{Intent.ActionSend},Categories = new[]{Intent.CategoryDefault},DataMimeType = "application/*",Label = "AndroidIntentFile")]
public class StartFileActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
if (Intent.Action == Intent.ActionSend && Intent.Extras.ContainsKey(Intent.ExtraStream))
{
var fileUrl = GetFilePath((Android.Net.Uri)Intent.Extras.GetParcelable(Intent.ExtraStream));
}
}
private string GetFilePath(Android.Net.Uri uri)
{
return uri.ToString ();
}
}
}
Getting below error
Unable to instantiate activity ComponentInfo{com.ppp.androidintentfile/com.ppp.androidintentfile.StartFileActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ppp.androidintentfile.StartFileActivity" on path: DexPathList[[zip file "/data/app/com.ppp.androidintentfile-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ppp.androidintentfile-1/lib/arm, /vendor/lib, /system/lib]]
Using class attributes and without making any hardcoded manifest additions:
Will automatically add to your manifest:
If you really need to remove the auto-generated name, provide a hard-code
Activity
name:Results in: