Greetings,
I am currently working on an app belonging to my company. The app is in two projects, one MVVM and the other the actual app. The actual app does nothing beyond start things, and the MVVM takes over for about everything else.
I've been trying to find a way to update the device, with little success currently. I've finally managed to make sure the device can find the file on the network, but I cannot get it to start the APK. Here's the relevant code.
public async static Task<bool> UpdateToServerVersion()
{
bool returnValue = false;
await Task.Run(() =>
{
try
{
SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8080");
string path = @"smb://Server/Share/IT/Androids/Picking.apk";
var auth = new NtlmPasswordAuthentication("Domain", "Login", "Password");
//Get target's SmbFile.
var file = new SmbFile(path, auth);
//Check if file exist
if (file.Exists())
{
Intent PromptInstall = new Intent(Intent.ActionView).SetDataAndType(Android.Net.Uri.Parse(file.GetPath()), "application/vnd.android.package-archive");
PromptInstall.SetFlags(ActivityFlags.GrantReadUriPermission);
PromptInstall.SetFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(PromptInstall);
}
else
{
returnValue = false;
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
returnValue = false;
}
});
return returnValue;
}
When it comes to the two projects, here is an image to show what it looks like:
![]()
The code shown above is within the "Helpers => common" from the Picking project, whereas the MainActivity is in Picking.Android. I presume the error I have is to do with it and prevent me from starting the intent.
Finally, here's the error returned when I try to run the code above:
No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://Domain/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }01-19 17:16:22.236 I/mono-stdout(12860): Android.Content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://Domain/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
at Android.Content.ContextWrapper.StartActivity (Android.Content.Intent intent) [0x00031] in :0
at Picking.Helpers.Common+<>c__DisplayClass46_0.b__0 () [0x00077] in
\cldRefactoring\cldRefactoring\Projects\1 Presentation\Picking-4.0\Picking\Picking\Helpers\Common.cs:937
--- End of managed Android.Content.ActivityNotFoundException stack trace ---
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://nascld/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1816)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.ContextImpl.startActivity(ContextImpl.java:791)
at android.app.ContextImpl.startActivity(ContextImpl.java:768)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
Thank you for your help and have a nice day