I'm new to UWP app and after 2 days of research I come to you…
I'm trying to run an executable from an uwp app so I looked at FullTrustProcess.
I added "Windows Desktop Extension for the UWP" to my references, my exe is in "Assets" folder and my manifest looks like this
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap mp rescap desktop">
<Identity
Name="22c57925-bd2a-4ebf-97e9-7a860ef17b3c"
Publisher="CN=charl"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="22c57925-bd2a-4ebf-97e9-7a860ef17b3c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>CustomCortanaCommands</DisplayName>
<PublisherDisplayName>charl</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="CustomCortanaCommands.App">
<uap:VisualElements
DisplayName="CustomCortanaCommands"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="CustomCortanaCommands"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\shutdown.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="SyncGroup" Parameters="/Sync"/>
<desktop:ParameterGroup GroupId="OtherGroup" Parameters="/Other"/>
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
</Application>
</Applications>
</Package>
Visual Studio keep telling me that this command does not exist in the current namespace
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
What i'm doing wrong ?? Please help me, it's frustrating to try to run an exe for 2 days...
Related
MainActivity.cs:
Java.IO.File file = new Java.IO.File(filePath);
Android.Net.Uri uri = FileProvider.GetUriForFile(this, "com.companyname.quickexam_final.FileProvider", file);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(uri, "application/pdf");
intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
this.StartActivity(intent);
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.quickexam_final" android:installLocation="auto">
<uses-sdk android:minSdkVersion="20" android:targetSdkVersion="28" />
<application android:allowBackup="true" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="#style/AppTheme" android:icon="#mipmap/ic_launcher">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.companyname.quickexam_final.FileProvider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/provider_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
Then, when I start my app I see a Toast
"We don't have access to open this file."
How can I solve this problem?
I would guess that this is because for persmissions that are regarded as dangerous, you need to explicitly request them. It is not enough just to have them in the manifest. To solve it you should use ActivityCompat.RequestPermissions to explicitly request access to these.
If you check the spec here it lists, for example, "READ_EXTERNAL_STORAGE" as a dangerous permission requiring an explicit prompt.
https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE
You can see here more about this issue:
https://developer.android.com/guide/topics/permissions/overview#dangerous-permission-prompt
I have finished my first xamarin android mobile app. It all works fine. I have only one problem that I cannot solve and I could not find solution using google.
When I start my app it all works great but when I press home button, open and close few other apps and come back to app it crashes. Also when I open app and go turn off my screen and then I turn it back on and to back to app it creshes.
Besides that all works great and there is no crashes.
This crash is happening both on emulator and on physical device.
The error I get when this happens on emulator is this:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.name.appname/com.name.android.publish.OverlayActivity}; have you declared this activity in your AndroidManifest.xml?
How to solve this if possible?
Edit:
AndoirdManifest.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.name.tournamentorganizer" android:installLocation="auto" android:versionName="1.1" android:versionCode="2">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowBackup="true" android:label="#string/app_name" android:icon="#drawable/icon11" android:name="android.app.Application" android:debuggable="true">
<activity android:label="Create new tournament" android:theme="#android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.createNewTournament" />
<activity android:label="Tournament Organizer" android:theme="#android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="Add new players" android:theme="#android:style/Theme.Material.Light" android:name="md5a2089f5b800658a06dd2a11fca5a1f83.addNewPlayers" />
<activity android:label="addGoalScorer" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.addGoalScorer" />
<activity android:label="All fixtures and results" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allFixturesAndResults" />
<activity android:label="Players database" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allPlayersActivity" />
<activity android:label="knockout4Players" android:name="md54d075dbf8b437fae408fa9e57e2203ba.knockout4Players" />
<activity android:label="League" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.leagueType" />
<activity android:label="My tournaments" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.myTournaments" />
<activity android:label="About" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.settings" />
<activity android:label="Player Info" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.stats" />
<activity android:label="table" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.table" />
<activity android:label="Top scorers" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.topScorerActivity" />
<activity android:label="Winners" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersActivity" />
<activity android:label="winnersAllTimeActivity" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersAllTimeActivity" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="com.name.tournamentorganizer.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.com.name.tournamentorganizer" />
</intent-filter>
</receiver>
<meta-data android:name="android.support.VERSION" android:value="25.4.0" />
</application>
</manifest>
Edit2:
I have app version with and without ads. The one without ads does not have this issue. The one with ads does have issue so the ads are problem somehow. I am using startapp ads.
you don't probably use the [Activity] code adornment
[Activity]
internal class YourActivity: Activity {}
If all your activities have
[Activity(Theme = "theme", Label = "name", MainLauncher = true)]
the MainLauncher argument set to true you will run into trouble.
The Activity annotation is used by Xamarin to configure/generate the AndroidManifest.xml
Have you included a MainApplication class, also tagged with the [Application] attribute? Looking at your manifest I am surprised to see the line
<application android:allowBackup="true" android:label="#string/app_name" android:icon="#drawable/icon11" android:name="android.app.Application" android:debuggable="true">
with android:name="android.app.Application". I would expect to see something with an md5 hash (i.e. md5xxx.MainApplication - or whatever the name of your Application class is)
A Clean and Rebuild maybe necessary after changing your application class
I work on an android app in Visual Studio.
When I implement a simple banner, the banner in this app says:
"Missing AdActivity with android:configChanges in AndroidManifest.xml."
I looked this issue up and many people had this problem but it always was in Android Studio. Can you help me out? I think it might have something to do with my manifest - which looks like that:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.TalkAboutTv2.TalkAboutTv2" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Talk About Tv"></application>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="#android:style/Theme.Translucent" />
</manifest>
THanks :)
You should make some changes to your code:
1) <activity> must be a child of the <application>
2) Add this
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>
to the <application> too.
This should result in the following code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.TalkAboutTv2.TalkAboutTv2" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Talk About Tv">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="#android:style/Theme.Translucent" />
</application>
</manifest>
I need the app to be able to list jpg files from folder "Photos".
I am stuck on reading jpg files from sd card on windows phone device.
What is done in order to resolve the problem:
created function to read files into collection. The function was
taken from basic sample called "RouteMapper"
ListBox to holding the list of files
permission to use sd card and jpg files
Function:
Photos = new ObservableCollection<ExternalStorageFile>();
private async void scanExternalStorage_Run()
{
// Clear the collection bound to the page.
Photos.Clear();
// Connect to the current SD card.
ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
// If the SD card is present, add GPX files to the Routes collection.
if (_sdCard != null)
{
try
{
// Look for a folder on the SD card named Routes.
ExternalStorageFolder photosFolder = await _sdCard.GetFolderAsync("Photos");
// Get all files from the Routes folder.
IEnumerable<ExternalStorageFile> photosFiles = await photosFolder.GetFilesAsync();
// Add each GPX file to the Routes collection.
foreach (ExternalStorageFile esf in photosFiles)
{
if (esf.Path.EndsWith(".jpg"))
{
Photos.Add(esf);
}
}
}
catch (FileNotFoundException)
{
// No Routes folder is present.
MessageBox.Show("The Routes folder is missing on your SD card. Add a Routes folder containing at least one .GPX file and try again.");
}
}
else
{
// No SD card is present.
MessageBox.Show("The SD card is mssing. Insert an SD card that has a Routes folder containing at least one .GPX file and try again.");
}
}
ListBox:
<ListBox
x:Name="jpgFilesListBox"
ItemsSource="{Binding Photos}"
SelectionChanged="jpgFilesListBox_SelectionChanged"
>
<!-- Each ListBox item is bound to the name of each GPX file -->
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock
Margin="0, 12, 0, 0"
Text="{Binding Name}"
Style="{StaticResource PhoneTextTitle2Style}"
/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
WMAppManifest.xml:
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_REMOVABLE_STORAGE" />
<Capability Name="ID_CAP_MAP" />
</Capabilities>
<Extensions>
<FileTypeAssociation TaskID="_default" Name="JPG" NavUriFragment="fileToken=%s">
<SupportedFileTypes>
<FileType ContentType="application/jpg">.jpg</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extensions>
Debugging revealed photosFolder.GetFilesAsync() returns 0.
While I definately have files in the "Photos" folder.
RouteMapper works fine and returns list of gpx files.
PS: I use emulator 8.1
Update: just for information. GetFolderAsync works and returns object that contains "D:\Photos"
Update2: Adding manifest files. I've got two of them after creating clean Windows Phone SilverLight blank App.
WMAppManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2014/deployment" AppPlatformVersion="8.1">
<DefaultLanguage xmlns="" code="en-US" />
<App xmlns="" ProductID="{dc1cb15e-1c8d-4635-a85e-e414e89455fb}" Title="CameraGPS" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="CameraGPS author" Description="Sample description" SDOptOut="false" BackUpOptOut="false" Publisher="CameraGPS" PublisherID="{4d13b339-1a9f-4a55-ba44-fe10cf0c0420}">
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_REMOVABLE_STORAGE" />
<Capability Name="ID_CAP_MAP" />
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="CameraGPSToken" TaskName="_default">
<TemplateFlip>
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
<Count>0</Count>
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
<Title>CameraGPS</Title>
<BackContent>
</BackContent>
<BackBackgroundImageURI>
</BackBackgroundImageURI>
<BackTitle>
</BackTitle>
<DeviceLockImageURI>
</DeviceLockImageURI>
<HasLarge>
</HasLarge>
</TemplateFlip>
</PrimaryToken>
</Tokens>
<Extensions>
<FileTypeAssociation TaskID="_default" Name="jpg" NavUriFragment="fileToken=%s">
<SupportedFileTypes>
<FileType ContentType="image/jpg">.jpg</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extensions>
<ScreenResolutions>
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
</ScreenResolutions>
</App>
</Deployment>
Package.appxmanifest:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="5b897434-732a-4f41-a110-db75375561c9" Publisher="CN=Qet" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="dc1cb15e-1c8d-4635-a85e-e414e89455fb" PhonePublisherId="4d13b339-1a9f-4a55-ba44-fe10cf0c0420" />
<Properties>
<DisplayName>CameraGPS</DisplayName>
<PublisherDisplayName>Qet</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="AGHost.exe" EntryPoint="MainPage.xaml">
<m3:VisualElements DisplayName="CameraGPS" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="CameraGPS" ForegroundText="light" BackgroundColor="#464646">
<m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
</m3:VisualElements>
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="jpg">
<DisplayName>Jpg</DisplayName>
<SupportedFileTypes>
<FileType ContentType="image/jpg">.jpg</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
<Extension Category="windows.accountPictureProvider" />
<Extension Category="windows.backgroundTasks" EntryPoint="AgHost.BackgroundTask">
<BackgroundTasks>
<Task Type="systemEvent" />
<m2:Task Type="location" />
</BackgroundTasks>
</Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="removableStorage" />
<Capability Name="picturesLibrary" />
<DeviceCapability Name="location" />
<DeviceCapability Name="webcam" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>AgHostSvcs.dll</Path>
<ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
</Package>
I have a problem implementing AdMob in my Xamarin.Forms project.
So when I run the android app this is shown in the output:
01-22 16:53:17.351 W/Ads (3529): Missing AdActivity with android:configChanges in AndroidManifest.xml.
You must have the following declaration within the <application> element:
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
But my Manifest got this line in it..:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
And when I open the page containing the ad this is showing:
What is wrong here ?
<activity> tag should be inside the <application> tag
<application>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>