Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to open any app on my android phone from within a blazor hybrid app (written in c#). On windows machines I can open local programs, using system.diagnostics.process.start, but I can't get it to work on Android.
I have tried to start apps with adb, and that works, for example:
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
but I cannot translate this to code in my blazor hybrid app.
In the end I want to be able to edit images with local software on android as well as on windows, as described here Edit Local Images/Text from a .NET MAUI Blazor Hybrid App -- Visual Studio Magazine[^] , but for now I would be glad if I could just launch an app.

What I have tried:

Tried to get process.start to work on Android by tinkering with the process and activity names, but to no avail.
Posted
Updated 26-Jan-24 19:18pm
v2

1 solution

Make a Method in MAUI, then expose it to your Blazor Hybrid app. You call the MAUI method and that will do the native Android work for you.

If you are not sure how to do this, there are plenty of examples: call maui method from a blazor hybrid app - Google Search[^]
 
Share this answer
 
Comments
Martijn van der Kaaij 30-Jan-24 4:59am    
With all due respect: the route is clear to me, and I've spent a lot of time on google for this, but I can't find an actual workking example of invoking an androis app from MAUI. Whatever I try, I'm getting "No such file or directory" errors when trying to launch from my app.
Graeme_Grant 30-Jan-24 5:10am    
Are you sure? Here: Launcher - .NET MAUI | Microsoft Learn[^] ... if you can do it from MAUI, you can do it from a hybrid app in MAUI.
Martijn van der Kaaij 30-Jan-24 6:42am    
Yiu're right, I'm not entirely stuck: I can get the example given at the link (with Lyft) to work, no problem. But then, if I try to translate it to get, for example, the camera to start (in adb shell: am start -n com.sec.android.app.camera/.Camera) I can't get it to work.
Martijn van der Kaaij 9-Feb-24 11:59am    
Launcher works now, Share as well.
- A user creates a text file in my app, and store it in external storage (using context.GetExternalFilesDir).
- I allow the user to open the file with an app of his choice (using Launcher or Share)
However, if the user tries to save the file, permission to write is denied. I added a FileProvider and played with it's settings, but it doesn't work. Exampless online are old, or not relevant for Blazor Hybrid.
Graeme_Grant 9-Feb-24 18:54pm    
You miss the point, it has nothing to do with Blazor. The code executes in MAUI.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900