windows runtime - Winrt Phone 8.1 Application share task functionality on Page works only once -
i have page in application share simple text, not working properly.
steps produce functionality.
go page click share shows application can share.
tap button => click again on share button.
this not open share screen time.
pasting code below:
protected override void onnavigatedfrom(navigationeventargs e) { _datatransfermanager.datarequested -= ondatarequested; this.navigationhelper.onnavigatedfrom(e); } protected override void onnavigatedto(navigationeventargs e) { _datatransfermanager = datatransfermanager.getforcurrentview(); _datatransfermanager.datarequested += ondatarequested; this.navigationhelper.onnavigatedto(e); } private void ondatarequested(datatransfermanager sender, datarequestedeventargs e) { e.request.data.properties.title = obj.title; htmldocument doc = new htmldocument(); doc.loadhtml(obj.description); string html = ""; foreach (htmlnode item in doc.documentnode.descendants()) { if (item.name == "body") { html = item.innerhtml; } } e.request.data.properties.description = html; e.request.data.settext(html); } private void appbarbutton_click_1(object sender, routedeventargs e) { //datatransfermanager.showshareui(); if (cmsservice.isconnectedtointernet()) { datatransfermanager.showshareui(); } else { contenttext.text = app.getresource("nointernetalert"); alertmessage.showasync(); } }
and while debugging share works time.
i suspect problem because unsubscribe _datatransfermanager.datarequested -= ondatarequested;
in onnavigatedfrom event. work fine when debugging, hence event won't raised - while debuging plm disabled , suspending/resuming events won't raised.
when running app normal, suspension invoke onnavigatedfrom, onnavigatedto won't raised upon resuming, there won't susbscription _datatransfermanager.datarequested += ondatarequested;
.
in case can use suspending/resuming (or other) events handle datatransfermanager.
Comments
Post a Comment