﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - Crosslight - How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Thu, 23 Oct 2014 01:40:39 GMT</pubDate><dc:creator>yudi</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Glad to hear that the snippet code helps.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Wed, 22 Oct 2014 07:56:49 GMT</pubDate><dc:creator>william.wen@yulon-energy.com.tw</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>It's work now, I can grab the Fragment from ViewModel, I appreciate that.</description></item><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Tue, 21 Oct 2014 22:38:19 GMT</pubDate><dc:creator>yudi</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Please try to use following snippet code to execute method in Android Fragment.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;MyFragment fragment = AndroidUtility.GetViewContext(this.Owner as IViewModel) as MyFragment;
            
if (fragment != null)
    fragment.DoSomethingInFragment();&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Mon, 20 Oct 2014 07:01:47 GMT</pubDate><dc:creator>william.wen@yulon-energy.com.tw</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Sorry I didn't mention the Fragment class is inherited "Intersoft.Crosslight.Android.Fragment&amp;lt;&lt;i&gt;customViewModel&lt;/i&gt;&amp;gt;". Error message &lt;b&gt;"Cannot convert type 'customViewModel' to 'Intersoft.Crosslight.Android.Fragment&amp;lt;Prototype.Ems.ViewModels.customViewModel&amp;gt;' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion" &lt;/b&gt;occurred when I use safe-cast statment on design time.&amp;nbsp;&lt;/p&gt;&lt;p&gt;It's ok when I code below:&lt;/p&gt;&lt;p&gt;customViewModel context = Owner as customViewModel;&lt;/p&gt;&lt;p&gt;It seemed error when I code below on runtime:&lt;/p&gt;&lt;p&gt;customViewModel context = Owner as customViewModel;&lt;/p&gt;&lt;p&gt;Fragment&amp;lt;customViewModel&amp;gt; customFragment = context.Context as Fragment&amp;lt;customViewModel&amp;gt;;&lt;/p&gt;&lt;p&gt;I still can't grab the&amp;nbsp;Fragment&amp;lt;customViewModel&amp;gt; to start my Android AnimationDrawable object, thank you very much.&lt;/p&gt;</description></item><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Sun, 19 Oct 2014 05:45:49 GMT</pubDate><dc:creator>nicholaslie</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>&lt;p&gt;Hi William,&lt;/p&gt;&lt;p&gt;I'm sure that you're already aware that each ViewModel represents a View, in this case, the Fragment is the View that consumes that your ViewModel.&lt;/p&gt;&lt;p&gt;So basically, in the ViewModel, you may call your custom service in the following fashion:&lt;/p&gt;&lt;pre&gt;ICustomService customService = ServiceProvider.GetService&amp;lt;ICustomService&amp;gt;();if (customService != null){
customService.SetOwner(this);
customService.ExecuteCustomMethod();
}&lt;/pre&gt;&lt;p&gt;&amp;nbsp;So, in your custom Android service, you can obtain the Context in the following fashion:&lt;/p&gt;&lt;pre&gt;Context context = this.DispatchContext(this.Owner);&lt;/pre&gt;&lt;p&gt;This is the whole key to the process. In Android, the Context object can be of three types: Activity, Fragment, or Global Application Context. Since you've associated the ViewModel to the Fragment, you've actually obtained the Fragment in the Context object, so you can easily safe-cast it to execute your public method in the Fragment.&lt;/p&gt;&lt;pre&gt;MyFragment fragment = context as MyFragment;
if (fragment != null)
{
fragment.ExecuteMyPublicMethod();
}&lt;/pre&gt;&lt;p&gt;Hope this helps.&amp;nbsp;&lt;/p&gt;</description></item><item><title>How AndroidMobileComponentServiceBase class interact another fragment</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-AndroidMobileComponentServiceBase-class-interact-another-fragment/</link><pubDate>Wed, 15 Oct 2014 09:08:35 GMT</pubDate><dc:creator>william.wen@yulon-energy.com.tw</dc:creator><category>android</category><category>AndroidMobileComponentServiceBase</category><description>&lt;p&gt;Hello, support team,&lt;/p&gt;&lt;p&gt;I created an AndroidMobileComponentServiceBase and custom service class in Android project to recieved the ViewModel message, but how can I raise event or execute public method in Android Fragment from this service class? (This Android fragment already created)&lt;/p&gt;&lt;p&gt;thanks'&lt;/p&gt;</description></item></channel></rss>