events - How to send OnActivityResult To a specific page in xamarin forms -
i using custom button renderer google sign in in xamarin forms page working fine signin resultin mainactivity want send data mainactivity , appdelegate particular page in xamarin forms.
protected override void onactivityresult(int requestcode, result resultcode, intent data) { base.onactivityresult(requestcode, resultcode, data); if (requestcode == 9001) { utilities.configuration.updateconfigvalue(utilities.constants.loggedinflag,string.empty); googlesigninresult result = android.gms.auth.api.auth.googlesigninapi.getsigninresultfromintent(data); if (result.issuccess) { googlesigninaccount acct = result.signinaccount; var token = acct.idtoken; //i wan send 'accnt' page in xamarin forms } else { //signin failure send response page in xamarin forms } } }
xamarin.forms runs in 1 activity on android. if url request comes out in different activity, have switch mainactivity before can use normal xf navigation.
i when user opens file associated app.
[activity(label = "launchfileactivity")] public class launchfileactivity : activity { protected override void oncreate(bundle bundle) { base.oncreate(bundle); if (intent.data != null) { var uri = intent.data; if (uri != null) { intent = new intent(this, typeof(mainactivity)); i.addflags(activityflags.reordertofront); i.putextra("filename", uri.path); this.startactivity(i); } } this.finishactivity(0); } }
and in mainactivity:
protected override void onnewintent(intent intent) { base.onnewintent(intent); intent = intent; } protected override void onpostresume() { base.onpostresume(); if (intent.extras != null) { string filename = intent.extras.getstring("filename"); if (!string.isnullorempty(filename)) { // filename } intent.removeextra("filename"); } }
Comments
Post a Comment