# Mining Hidden and Fragmented API Usages in Android Applications
## 8 Discussion and Threats to Validity  
The fragmented or hidden API usages accounted of 23% in our dataset. Such problematic usages tended to contain the APIs inherited from Android library classes. Table 3 presents the top three APIs that appeared in the hidden and fragmented usages. For example, the most popular API in each problematic usage was setContentView() and supportStartPostponedEnterTransition(), respectively. These APIs were defined in the Android class Activity, which aims to manage the lifecycle and user interfaces in Android applications. The other methods in Table 3 were also defined in the Android classes that were inherited by the developer-written classes. These results supported that the inherited methods incurred hidden or fragmented usages.  
The influence of fragmented and hidden usages on code completion was significant. The accuracy was improved by at most 5.55% with the API generalization. A feasible explanation is that the API generalization reduces the number of observable outputs in each HAPI model. For example, in Figure 6, the raw sequence consisted of five methods, setVisibility() and setEnabled() of RelativeLayout, setEnabled() of EditText, and setVisibility() and setText() of WPTextView. In contrast, the generalized sequence consisted of four methods, setVisibility() and setEnabled() of View and TextView, respectively. This difference helped the HAPI model consider fewer methods and classes.  
Another feasible explanation is that the fragmented usages degraded the accuracy of the code completion. Figure 10 presents the accuracy of the code completion only for the fragmented usages, all of which consisted of multiple classes.  
Regardless of the threshold, the accuracy was always higher with the generalized usages than with the raw usages. The maximum difference was 6.66% observed at the top two recommendation,  
Figure 10: Comparison between raw and generalized APIs.  
\begin{table}
\begin{tabular}{c l} \hline \hline
**Group** & **API Ranking** \\ \hline Hidden & 1. AppCompatActivity.setContentView() \\  & 2. CursorWrapper.getColumnIndex() \\  & 3. Fragment.setHasOptionMenu() \\ \hline Fragmented & 1. FragmentActivity.supportStartPostponedEnterTransition() \\  & 2. CursorLoader.setSelection() \\  & 3. CursorLoader.setSelectionArgs() \\ \hline \hline \end{tabular}
\end{table}
Table 3: Most frequently observed APIs in each group.  
whereas the minimum was 4.08% observed at the top eight. This result implies that the API usages learned from the generalized usages were more predictable than the fragmented usages.  
Our study focused on the code completion task. However, API usage mining has been used in various applications such as code search or bug prediction. The proposed API generalization would influence such applications. In addition, it is necessary to confirm whether the generalization was effective even with the larger dataset and on various platforms other than Android and Java.  
A threat to validity could be introduced due to the possibility of bugs in the mining tools, such as Eclipse JDT, that were used in our experiments. Similarly, the class hierarchy may have been resolved incorrectly due to the bugs in the build tool or Eclipse JDT. We used the most recent build version in which several bugs have been corrected.