-
Notifications
You must be signed in to change notification settings - Fork 0
/
Activity_File_Import.cs
33 lines (30 loc) · 1.08 KB
/
Activity_File_Import.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Android.App;
using Android.Content;
using Android.OS;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace ShishaBacon
{
[Activity(Label = "ShishaBacon Importer")]
[IntentFilter(new[] { "android.intent.action.VIEW"}, DataMimeType = "application/json", Categories = new[] { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE" })]
public class Activity_File_Import : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
try
{
Stream stream = ContentResolver.OpenInputStream(Intent.Data);
string res = new StreamReader(stream).ReadToEnd();
if (!string.IsNullOrWhiteSpace(res))
TabaccoList.ImportList(new List<Tabacco>(JsonConvert.DeserializeObject<Tabacco[]>(res)));
}
catch (Exception)
{
}
StartActivity(typeof(MainActivity));
}
}
}