Permission Denial: reading androidx.core.content.FileProvider - android-studio
for this example
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
File fileWithinMyDir = new File(targetPdf);
if (fileWithinMyDir.exists()) {
intentShareFile.setType("application/pdf");
Uri uri = FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID + ".provider", fileWithinMyDir);
intentShareFile.setClipData(ClipData.newRawUri("", uri));
intentShareFile.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intentShareFile.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intentShareFile, "sending file..."));
}
For images:
Change
intentShareFile.setType("application/pdf");
to
intentShareFile.setType("image/*");
It's work in Android 10, 11, 12
https://developer.android.com/reference/androidx/core/content/FileProvider
Related
SharePoint Onlinie - Create Drive using graph service client
I am working on one project where I've to create a drive (document library) on SharePoint in not exists. Using following code: var newRRRDrive = new Drive { Name = "RRRR-Prod1", Description = "Holds RRRR files", AdditionalData = new Dictionary<string, object>() { {"#microsoft.graph.conflictBehavior","rename"} } }; var newDrive = await graphClient .Sites[site.Id] .Drives .Request() .AddAsync(newRRRDrive); But this is throwing exception that the request is invalid. I don't know what I doing wrong here.. Any suggestions? Code: invalidRequest Message: Invalid request Inner error: AdditionalData: date: 2021-05-30T20:57:40 request-id: ec6ddddddddddddddd0f72d91c8e client-request-id: ec6ddddddddddddddddddddddddddddddddd ClientRequestId: ec6dedddddddddddddddddddddddddddddddddddddddddddd Adding image after implementing soln by Michael enter image description here
To create a new document library, you can perform the same call as mentioned in the create list instead of using the genericList template value. Use the documentLibrary value. POST /sites/{site-id}/lists Content-Type: application/json { "displayName": "YourLibraryName", "list": { "template": "documentLibrary" } } C# code var list = new List { DisplayName = "Books", ListInfo = new ListInfo { Template = "documentLibrary" } }; await graphClient.Sites["{site-id}"].Lists .Request() .AddAsync(list);
Enable Azure SQL Server Auditing with Pulumi
I am trying to enable auditing on an Azure SQL server resource with a Pulumi stack. However, the setting never turns on with the script that I have. I've looked at various blogs and ARM templates for how it looks, but the blogs always mention you need to enable auditing on the master database in order to have this setting enabled. The setting I am trying to enable through Pulumi is shown below My pulumi stack is shown here: var dbServer = new AzureNative.Sql.Server("dbServer", new AzureNative.Sql.ServerArgs { ServerName = dbServerName.ToLower(), ResourceGroupName = resourceGroupName, AdministratorLogin = username, AdministratorLoginPassword = password, Version = "12.0", MinimalTlsVersion = "1.2", PublicNetworkAccess = AzureNative.Sql.ServerPublicNetworkAccess.Enabled, Tags = tags, }); var serverDiagnosticSetting = new Pulumi.AzureNative.Insights.DiagnosticSetting("serverDiagnosticSetting", new Pulumi.AzureNative.Insights.DiagnosticSettingArgs { Logs = { new Pulumi.AzureNative.Insights.Inputs.LogSettingsArgs { Category = "SQLSecurityAuditEvents", Enabled = true, RetentionPolicy = new Pulumi.AzureNative.Insights.Inputs.RetentionPolicyArgs { Days = 0, Enabled = false, }, } }, Name = "mydiagnosticsettings", ResourceUri = dbServer.Id, WorkspaceId = logAnalyticsId, }, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}}); var serverBlobAuditingPolicy = new AzureNative.Sql.ServerBlobAuditingPolicy("serverBlobAuditingPolicy", new AzureNative.Sql.ServerBlobAuditingPolicyArgs { AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP", }, BlobAuditingPolicyName = "sqlAuditingPolicy", ResourceGroupName = resourceGroupName, ServerName = dbServer.Name, State = Pulumi.AzureNative.Sql.BlobAuditingPolicyState.Enabled, IsAzureMonitorTargetEnabled = true, StorageAccountSubscriptionId = "00000000-0000-0000-0000-000000000000" }, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}}); Running this stack, however, the setting is never enabled.
You cannot configure a diagnostic setting on the server directly. You have to use the master database URI var databaseMaster = dbServer.Id.Apply(id => id+"/databases/master"); var serverDiagnosticSetting = new Pulumi.AzureNative.Insights.DiagnosticSetting("serverDiagnosticSetting", new Pulumi.AzureNative.Insights.DiagnosticSettingArgs { Logs = { new Pulumi.AzureNative.Insights.Inputs.LogSettingsArgs { Category = "SQLSecurityAuditEvents", Enabled = true, RetentionPolicy = new Pulumi.AzureNative.Insights.Inputs.RetentionPolicyArgs { Days = 0, Enabled = false, }, } }, Name = "mydiagnosticsettings", ResourceUri = databaseMaster, WorkspaceId = logAnalyticsId, }, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}});
How to set output contexts while creating a intent in dialogflow PHP?
I am trying to set output context to a particular intent via v2 create intent API. Please check my code. use Google\Cloud\Dialogflow\V2\SessionsClient; use Google\Cloud\Dialogflow\V2\TextInput; use Google\Cloud\Dialogflow\V2\QueryInput; use Google\Cloud\Dialogflow\V2\IntentsClient; use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase_Part; use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase; use Google\Cloud\Dialogflow\V2\Intent_Message_Text; use Google\Cloud\Dialogflow\V2\Intent_Message; use Google\Cloud\Dialogflow\V2\Intent; use Google\Cloud\Dialogflow\V2\Context; use Google\Cloud\Dialogflow\V2\ContextsClient; private function intent_create(){ putenv('GOOGLE_APPLICATION_CREDENTIALS='.getcwd() . '/strive_stage.json'); $intentsClient = new IntentsClient(); /** Create Intent **/ $disaplayName = "Where is Goa"; $utterances = ["Goa", "Where is Goa"]; // prepare training phrases for intent $trainingPhrases = []; foreach ($utterances as $trainingPhrasePart) { $part = new Intent_TrainingPhrase_Part(); $part->setText($trainingPhrasePart); // create new training phrase for each provided part $trainingPhrase = new Intent_TrainingPhrase(); $trainingPhrase->setParts([$part]); $trainingPhrases[] = $trainingPhrase; } $messageTexts = 'Goa is in India.'; // prepare messages for intent $text = new Intent_Message_Text(); $text->setText([$messageTexts]); $message = new Intent_Message(); $message->setText($text); $createIntentObject = $intentsClient->projectAgentName(env("DIALOG_FLOW_PROJECT_ID")); // prepare intent $intent = new Intent(); $intent->setDisplayName($disaplayName); $intent->setTrainingPhrases($trainingPhrases); $intent->setMessages([$message]); $contexts = ['test']; foreach($contexts as $con){ $contextObj = new Context(); $contextObj->setName($con); $contextData[] = $contextObj; $intent->setOutputContexts($contextData); } // $intent->getOutputContexts('test'); //dd($intent); $response = $intentsClient->createIntent($createIntentObject, $intent); printf('Intent created: %s' . PHP_EOL, $response->getName()); } I am getting error message { "message": "com.google.apps.framework.request.BadRequestException: Resource name does not match format 'projects/{project_id}/agent/sessions/{session_id}/contexts/{context_id}' or 'projects/{project_id}/locations/{location_id}/agent/sessions/{session_id}/contexts/{context_id}'.", "code": 3, "status": "INVALID_ARGUMENT", "details": [] } I believe the issue is with the format of storing the output context. Please help me on this.
I had the same issue. The answer is to not put in the bare name, but to have a string of a certain format made see http://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.131.0/dialogflow/v2/intent?method=setOutputContexts // $projectId your project id // $sessionId can be anything, I use $sessionId = uniqid(); $uri = "projects/$projectId/agent/sessions/$sessionId/contexts/$con"; $contextObj->setName($uri);
I can see that there are any response about this topic. I leave here my solution for the next generations To create a output context you need to create the correct format, for this objetive you can use Context class Google\Cloud\Dialogflow\V2\Context private function parseoOutputContexts($contexts, $project_id, $lifespan = 5) { $newContexts = array(); foreach ($contexts as $context) { $newContexts[] = new Context( [ 'name' => 'projects/' . $project_id . '/agent/sessions/-/contexts/' . $context, 'lifespan_count' => $lifespan ] ); } return $newContexts; } And you can use this function to finnaly add the output context to the object Intent. $dialogflow_intent = new Intent(); $output_contexts = ['output_context_1'. 'output_context_2']; $output_contexts = $this->parseOutputContexts($output_contexts, '[YOUR_PROJECT_ID]'); $dialogflow_intent->setOutputContexts($output_contexts);
NamespaceManager.CreateSubscription throws MessagingEntityNotFoundException
I've also set up other subscriptions and they work. But when I'm trying to empty the queue of a subscription, the subscription no longer exists. What I'm trying to do is make a new subscription if (!namespaceManager.SubscriptionExists(TopicName, SubscriptionName)) { SubscriptionDescription subscription = new SubscriptionDescription(TopicName, SubscriptionName) { DefaultMessageTimeToLive = TimeSpan.FromDays(1), LockDuration = TimeSpan.FromSeconds(20), EnableDeadLetteringOnMessageExpiration = true, EnableDeadLetteringOnFilterEvaluationExceptions = true }; namespaceManager.CreateSubscription(subscription); } The last line (CreateSubscription) throws a MessagingEntityNotFoundException. Am I missing something?
Problem solved. Had to make a topic first. if (!namespaceManager.TopicExists(TopicName)) { var td = new TopicDescription(TopicName); td.MaxSizeInMegabytes = 5120; namespaceManager.CreateTopicAsync(td); }
RaphaelJs - Issues with Hovering due to Object
Cheers, for my website I try to spice my CV a little up. If you hover about an Icon on canvas_2, which I created as an Object, a static shape + dynamic message will appear on canvas_3 (canvas_1 is solely for navigation, which does not matter at this point). However if I hover over the first Object, the second Object, not the first, fires its animation and displays the description. I set up a fiddle, maybe this will clear things up better than my english. http://jsfiddle.net/J6h7e/4/ function Achievement(set, rect, circ, symb, label, text, icon) { var ach = this; ach.set = set; ach.rect = rect; ach.circ = circ; ach.symb = symb; ach.lab = label; ach.desText = text; ach.desIcon = icon; ach.builder = function() { ach.cir = canvas_2.path(circ); ach.sym = canvas_2.path(symb); ach.set.push(ach.rect, ach.sym, ach.cir); ach.set.attr({"stroke":"none", "fill":"rgb(238, 238, 238)"}); ach.rect.attr({"opacity":0}); } ach.hoverSetup = function() { ach.set.mouseover( function(){ ach.set.forEach(function(el){el.animate(el.transform("s1.25"), "bounce")}); achTemplate.attr({"opacity":1}); ach.description.attr({"opacity":1}); } ); ach.set.mouseout( function(){ach.set.forEach(function(el){el.animate(el.transform("s1"), "elastic")}); achTemplate.attr({"opacity":0}); ach.description.attr({"opacity":0}); } ) } ach.descriptor = function() { canvas_3.setStart(); ach.des = canvas_3.text(320, 60, ach.desText); ach.ico = canvas_3.path(ach.desIcon).attr({"stroke":"none"}); ach.description = canvas_3.setFinish(); ach.description.attr({"font-family":"cabinregular", "font-size":"14px", "fill":"rgb(25,106,141)", "text-anchor":"start", "opacity":0}); } console.log(ach.set); return ach; } /*Static Content*/ var title = canvas_2.text(200, 20, 'Achievements'); title.attr({"font-family": 'franchiseregular',"font-size": '24','stroke-width': '0','stroke-opacity': '1','fill': 'rgb(238,238,238)'}); var achTemplate = canvas_3.set(); var templ = canvas_3.path("M635.5,57c0,27.615-18.851,50-42.105,50H277.605c-23.253,0-42.105-22.385-42.105-50l0,0 c0-27.613,18.853-50,42.105-50h315.789C616.649,7,635.5,29.387,635.5,57L635.5,57z");templ.attr({"stroke":"none", "fill":"rgb(238,238,238)"}); var templHe = canvas_3.text(410, 20, "Achievement Unlocked"); templHe.attr({"font-family":"cabinsemibold", "font-size":"18px", "fill":"rgb(25, 106, 141)", "font-weight":"bold" }); var tempCir = canvas_3.path("M260.75,55.884c0-0.714,0.04-1.417,0.117-2.111l-10.838-3.522c-0.346,1.824-0.529,3.707-0.529,5.633 c0,8.626,3.644,16.404,9.472,21.875l6.696-9.217C262.614,65.206,260.75,60.762,260.75,55.884z M298.25,55.884 c0,4.877-1.863,9.322-4.918,12.658l6.695,9.217c5.828-5.471,9.473-13.248,9.473-21.875c0-1.926-0.184-3.809-0.531-5.632 l-10.84,3.521C298.21,54.466,298.25,55.169,298.25,55.884z M283.25,37.509c5.387,1.093,9.934,4.495,12.566,9.131l10.84-3.521 c-4.29-9.107-13.024-15.706-23.406-17.003V37.509z M263.184,46.642c2.631-4.634,7.18-8.037,12.566-9.131V26.117 c-10.382,1.297-19.116,7.896-23.404,17.004L263.184,46.642z M287.266,72.954c-2.365,1.078-4.992,1.68-7.766,1.68 c-2.773,0-5.4-0.602-7.766-1.68l-6.698,9.217c4.29,2.365,9.219,3.713,14.463,3.713s10.174-1.348,14.464-3.713L287.266,72.954z"); tempCir.attr({"stroke":"none", "fill":"rgb(25, 106, 141)"}); achTemplate.push(templ, templHe, tempCir); achTemplate.attr({"opacity":0}); var tooltip = canvas_3.path("M34.308,44c-3.472,0-6.737,1.352-9.192,3.808c-2.456,2.455-3.808,5.721-3.808,9.192s1.352,6.737,3.808,9.192 C27.57,68.648,30.836,70,34.308,70s6.737-1.352,9.192-3.808c2.456-2.455,3.808-5.721,3.808-9.192s-1.352-6.737-3.808-9.192 C41.045,45.352,37.779,44,34.308,44z M34.308,41L34.308,41c8.837,0,16,7.163,16,16s-7.163,16-16,16s-16-7.163-16-16 S25.471,41,34.308,41z M32.308,63h4v4h-4V63z M32.308,47h4v12h-4V47z"); tooltip.attr({"stroke":"none", "fill":"rgb(238, 238, 238)", "title":"Hover over the Symbols to get more Information"}); /*Berlin Achievement */ var ber = canvas_2.set(); var selBe = canvas_2.rect(89.466, 109, 60.001, 60); var berlin = Achievement ( ber, selBe, "M100.92,138.885c0-0.714,0.039-1.417,0.117-2.111L90.2,133.251c-0.347,1.824-0.529,3.707-0.529,5.633 c0,8.626,3.644,16.404,9.472,21.875l6.696-9.217C102.784,148.207,100.92,143.763,100.92,138.885z M138.42,138.885 c0,4.877-1.863,9.322-4.918,12.658l6.695,9.217c5.828-5.471,9.473-13.248,9.473-21.875c0-1.926-0.184-3.809-0.531-5.632 l-10.84,3.521C138.381,137.467,138.42,138.169,138.42,138.885z M123.42,120.51c5.387,1.093,9.934,4.495,12.566,9.131l10.84-3.521 c-4.289-9.107-13.023-15.706-23.406-17.003V120.51z M103.354,129.642c2.631-4.634,7.18-8.037,12.566-9.131v-11.395 c-10.383,1.297-19.116,7.896-23.404,17.004L103.354,129.642z M127.436,155.955c-2.365,1.078-4.992,1.68-7.766,1.68 s-5.4-0.602-7.766-1.68l-6.699,9.217c4.291,2.365,9.22,3.713,14.463,3.713c5.246,0,10.176-1.348,14.465-3.713L127.436,155.955z", "M119.67,126.938c-4.143,0-7.5,3.357-7.5,7.5c0,7.5,7.5,16.5,7.5,16.5s7.5-9,7.5-16.5 C127.17,130.295,123.813,126.938,119.67,126.938z M119.67,139.033c-2.537,0-4.594-2.057-4.594-4.594s2.057-4.594,4.594-4.594 s4.594,2.057,4.594,4.594S122.208,139.033,119.67,139.033z M116.765,134.438c0,1.605,1.301,2.906,2.906,2.906 c1.604,0,2.905-1.301,2.905-2.906s-1.301-2.906-2.905-2.906C118.065,131.533,116.765,132.833,116.765,134.438z", "The Passenger", "250G - The Passenger \n Moved to Berlin \n Unlocked on 09/08/2004", "M279.764,44.938c-4.143,0-7.5,3.357-7.5,7.5c0,7.5,7.5,16.5,7.5,16.5s7.5-9,7.5-16.5 C287.264,48.295,283.906,44.938,279.764,44.938z M279.764,57.031c-2.537,0-4.594-2.056-4.594-4.593s2.057-4.594,4.594-4.594 s4.594,2.057,4.594,4.594S282.301,57.031,279.764,57.031z M276.858,52.438c0,1.605,1.301,2.906,2.906,2.906 c1.605,0,2.906-1.301,2.906-2.906s-1.301-2.906-2.906-2.906C278.159,49.532,276.858,50.833,276.858,52.438z" ); berlin.builder(); berlin.hoverSetup(); berlin.descriptor(); /*Python Achievement */ var py = canvas_2.set(); var selPy = canvas_2.rect(89.795, 362.5, 60, 60); var python = Achievement ( py, selPy, "M101.045,392.384c0-0.713,0.04-1.416,0.117-2.109l-10.839-3.521c-0.347,1.824-0.528,3.707-0.528,5.633 c0,8.627,3.645,16.405,9.473,21.876l6.695-9.217C102.91,401.706,101.045,397.262,101.045,392.384z M138.545,392.384 c0,4.878-1.863,9.322-4.918,12.659l6.695,9.217c5.828-5.471,9.473-13.249,9.473-21.876c0-1.926-0.184-3.809-0.531-5.631 l-10.84,3.521C138.506,390.966,138.545,391.669,138.545,392.384z M123.545,374.009c5.387,1.094,9.934,4.496,12.566,9.132 l10.84-3.521c-4.289-9.107-13.023-15.707-23.406-17.004V374.009z M103.48,383.142c2.631-4.635,7.18-8.037,12.564-9.131v-11.395 c-10.382,1.297-19.115,7.896-23.402,17.004L103.48,383.142z M127.561,409.455c-2.363,1.078-4.99,1.68-7.766,1.68 c-2.771,0-5.398-0.602-7.767-1.68l-6.697,9.217c4.29,2.365,9.22,3.713,14.463,3.713c5.245,0,10.175-1.348,14.464-3.713 L127.561,409.455z", "M127.295,390.938h-1.5v-4.5c0-3.313-2.688-6-6-6s-6,2.688-6,6v4.5h-1.5c-0.824,0-1.5,0.678-1.5,1.5v10.5 c0,0.825,0.676,1.501,1.5,1.501h15c0.824,0,1.5-0.676,1.5-1.501v-10.5C128.795,391.614,128.119,390.938,127.295,390.938z M119.795,399.938c-0.828,0-1.5-0.671-1.5-1.5c0-0.828,0.672-1.5,1.5-1.5c0.83,0,1.5,0.672,1.5,1.5 C121.295,399.268,120.625,399.938,119.795,399.938z M122.795,390.938h-6v-4.5c0-1.652,1.348-3,3-3c1.654,0,3,1.348,3,3V390.938z", "Rattlesnake", "250G - Rattlesnake \n Mastering Python \n Not yet Unlocked", "M287.264,54.5h-1.5V50c0-3.313-2.688-6-6-6c-3.313,0-6,2.687-6,6v4.5h-1.5c-0.824,0-1.5,0.676-1.5,1.5v10.5 c0,0.824,0.676,1.5,1.5,1.5h15c0.824,0,1.5-0.676,1.5-1.5V56C288.764,55.176,288.088,54.5,287.264,54.5z M279.764,63.5 c-0.829,0-1.5-0.671-1.5-1.5s0.671-1.5,1.5-1.5s1.5,0.671,1.5,1.5S280.593,63.5,279.764,63.5z M282.764,54.5h-6V50 c0-1.654,1.346-3,3-3c1.654,0,3,1.346,3,3V54.5z" ); python.builder(); python.hoverSetup(); python.descriptor(); }
You have missed the new keyword when creating new instance of the Achievement object. like: var berlin = new Achievement(); var python = new Achievement(); http://jsfiddle.net/J6h7e/5/ BTW: Nice animation :)