activity = Xamarin.Forms.Forms.Context as MainActivity not actual context

Hi, 
I am new in xamarin and In an exemble I have this

 activity = Xamarin.Forms.Forms.Context as MainActivity;
            activity.ActivityResult += (object sender, ActivityResultEventArgs e) =>
            {

the problem is I want to have the currentactivity to replace mainactivity.

Is it possible to do that?

Thank you

3 Replies

SG Sivaram Ganesan Syncfusion Team May 8, 2018 12:14 PM UTC

Hi Bleas, 
 
We assume that you are trying to change the main launcher of the application. You can set MainLauncher attribute to true for new activity and set as false for any other activities in the application. Please refer the below link in which “SplashActivity” is set as MainLauncher.  
 
Link :- https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen#create-a-splash-activity 
 
Regards, 
Sivaram.G 



CB Christian Bleas May 9, 2018 05:35 AM UTC

Thank you for this answer. I saw this solution at first.
But I work on an application with a lot of  différent forms is it possible in that case to have the specific Activity for every form to use activity.ActivityResult += (object sender, ActivityResultEventArgs e) =>?

Second
Xamarin.Forms.Forms.Context is obsolete in version 2.5
How can I change it to use your exemple "ImageEditor_GettingStarted"?
thank you



SG Sivaram Ganesan Syncfusion Team May 13, 2018 05:51 PM UTC

Hi Bleas,

Regarding ”having multiple activities in a single Xamarin.Forms application”,

 

Xamarin.Forms applications are single activity applications and having multiple activities may result in improper navigations as discussed in the below link.


https://forums.xamarin.com/discussion/65395/does-xamarin-forms-always-use-a-single-android-activity 
https://forums.xamarin.com/discussion/52794/android-how-to-use-loadapplication-when-having-multiple-activities

 

Regarding ” How can I change it to use your exemple "ImageEditor_GettingStarted"?

Since Xamarin.Forms.Forms.Context is obsolete in xamarin version in 2.5, we have modified getting context as activity from "ImageEditor_GettingStarted" Forms.Android MainActivity class.

Please get the sample for the same from the below link,

http://www.syncfusion.com/downloads/support/directtrac/general/ze/ImageEdit1432435663 


Please get back us , if you need any further assistance.

Regards,

Sivaram G



Loader.
Up arrow icon