AFAIK implicit constructor visibility reflects the owner class visibility. 
Hence, constructor is public if fragment class visibility is public.

On May 9, 2014, at 1:27 PM, Christopher Orr <[email protected]> wrote:

> On 06/05/14 19:20, 'Tor Norbye' via adt-dev wrote:
>> On Tue, May 6, 2014 at 1:48 AM, Roman Mazur <[email protected]
>> <mailto:[email protected]>> wrote:
>> 
>>    Currently 'ValidFragment' check produces an error if default
>>    fragment constructor in implicit.
>>    To be honest, I'm not satisfied with such a behaviour because it
>>    makes me add an empty constructor explicitly to a bunch of classes...
>> 
>> 
>> That's a bug. I discovered it myself yesterday and fixed it:
>> https://android-review.googlesource.com/#/c/93424/
> 
> I don't think that was a bug.
> 
> AFAIK, Android explicitly requires an empty *public* constructor for 
> Fragments.  I believe Java implicit constructors have default visibility.
> 
> From the Javadoc:
> "Every fragment must have an empty constructor, so it can be instantiated 
> when restoring its activity's state." (though here it doesn't actually say 
> "public")
> http://developer.android.com/reference/android/app/Fragment.html#Fragment()
> 
> The Android Studio "blank activity with fragment" creates a Fragment with 
> empty public constructor, and various code samples on the Android site show 
> explicit public constructors, e.g.:
> http://android-developers.blogspot.de/2012/05/using-dialogfragments.html
> 
> If you don't provide a public constructor, at some point when the system 
> attempts to re-instantiate your fragment after restarting your process from 
> the background, you'll likely run into this ClassNotFoundException:
> https://github.com/android/platform_frameworks_base/blob/android-4.4.2_r2/core/java/android/app/Fragment.java#L596-599
> 
> Regards,
> Chris
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "adt-dev" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/adt-dev/aKRNyi8OSBM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> For more options, visit https://groups.google.com/d/optout.

---
Best regards, 
Roman Mazur 

Software engineer at Stanfy (http://stanfy.com.ua)
Skype: roman.mazur.f
LinkedIn: http://ua.linkedin.com/in/romanmazur
Twitter: http://twitter.com/roman_mazur

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to